jQuery highlight all terms

后端 未结 4 1444
南旧
南旧 2021-01-27 15:23

I\'m trying to highlight search terms but it doesn\'t split the words. Two words take as a one string and highlights only the string as is.

In the demo you can see that

4条回答
  •  没有蜡笔的小新
    2021-01-27 15:50

    Try this, it should highlight the whole string and words inside.

    var searchterm = "Windows XP";
    var tohighlight = searchterm.split(" ");
    tohighlight.push(searchterm);
    $("p,a").highlight(tohighlight);
    

提交回复
热议问题