0

I asked a question before but I need a bit more information. I found this great snippet for searching FAQ items:

http://jsfiddle.net/pT6dB/

I want to find a question containing "round and "Earth". However, if I type "round Earth" in looks specifically for "round Earth" which it cant find. I want it to be an "AND" query.

Would this be an easy modification?

4

2 に答える 2

2

各用語を個別に検索し、クエリを作成する必要があります。

var term = $(this).val().trim();

var words = term.split(' ');

var selector = "#result LI";

for(var i = 0; i < words.length; i++){
    selector += ':contains(' + words[i] + ')'
}

$(selector).show();

更新:大文字と小文字を区別しない追加のフィドルがあります

http://jsfiddle.net/pT6dB/

于 2012-07-28T19:44:21.467 に答える