1
以下の "dev関数"では、 "html"変数の文字列とspanタグの内容の小文字と小文字の比較を実行するために、文字列を小文字に変換しようとしています。jQueryとの比較はできませんか?
ハイライトクラスは添付されていないよう以来、小文字にスパンを変換しようとしたとき、私はdevの関数に間違った何かをしなければなりません...
var html = jQuery('#content').html().toLowerCase();
//existing function works when the span is preset to lowercase
jQuery(".my_kw").find("span").filter(function() {
return html.indexOf(jQuery(this).html()) != -1;
}).each(function() {
jQuery(this).addClass('highlight');
});
}
//dev function. Trying to allow for spans to be mixed case, and force to lowercase only for comparison
jQuery(".my_kw").find("span").filter(function() {
var kw = jQuery(this).toLowerCase();
return html.indexOf(kw.html()) != -1;
}).each(function() {
jQuery(this).addClass('highlight');
});
}
+1それでした!このコードを長く見ています。簡単な修正。 –
このケースでは答えを受け入れることを忘れないでください) –
ありがとうございます。あなたは少なくとも6分待たなければなりません:-) –