我试图突出显示搜索条件,它运行良好。问题是我想避免使用1或2个字符的单词或“the”和“and”。jQuery检测字符串的长度
如果我使用
var term = $('#q').val().split(/\s+/);
if(term.length < 3){
$('p').highlight(term);
}
将需要输入值整个字符串,所以它有更多然后3个字母。
所以我想我需要使用
if(term:contains('and')){}
但诀窍是如何将我未强调?
higlihgt函数是从https://raw.github.com/bartaz/sandbox.js/master/jquery.highlight.js – SamotnyPocitac