我们使用mark.js突出显示文档中搜索的文本,并跳到文档中--使用来自http://jsfiddle.net/wy3tbvnq/2/的示例。
请搜索:"Lorem“-> 高亮显示是完美的,但是跳到文本片段跳到 "lorem ",然后跳到" ipsum”,然后跳到“lorem”。它应该跳到Lorem ipsum和next Lorem ipsum。
我的问题是,我们有多个跨标签的文本。和<span>lorem</span><span>ipsum</span>一样,我们搜索lorem。非常适合高亮显示,但是跳到搜索的文本会导致跳转到"lorem“和跳到"ipsum”--因为它们都有一个突出显示类。
发布于 2020-04-10 10:35:36
只需伪造属性,检查更新的:- 琴键
$content.unmark({
done: function() {
$content.mark(searchVal, {
separateWordSearch: false, //update this properties
done: function() {
$results = $content.find("mark");
currentIndex = 0;
jumpTo();
}
});
}
});`
https://stackoverflow.com/questions/61138199
复制相似问题