0
我已經添加了代碼來覆蓋contains方法,但是我仍然沒有得到正確的結果。我創建了一個JFiddle來顯示問題。 http://jsfiddle.net/zjAyX/我也嘗試了與我使用的jQuery版本jQuery 1.8兼容的代碼。我在哪裏放置代碼?:包含區分大小寫不能正常工作
$(function() {
$.extend($.expr[":"], {
"containsIN": function(elem, i, match, array) {
return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
}
});
$("#searchInput").keyup(function() {
//split the current value of searchInput
var data = this.value.split(" ");
//create a jquery object of the rows
var jo = $("tbody").find("tr");
if (this.value == "") {
jo.hide();
return;
}
//hide all the rows
jo.hide();
//Recusively filter the jquery object to get results.
jo.filter(function (i, v) {
var $t = $(this);
for (var d = 0; d < data.length; ++d) {
if ($t.is(":contains('" + data[d] + "')")) {
return true;
}
}
return false;
})
//show the rows that match.
.show();
}).focus(function() {
this.value = "";
$(this).css({
"color": "black"
});
$(this).unbind('focus');
}).css({
"color": "#C0C0C0"
});
});
它可以在你鏈接的小提琴罰款... – Anton
小提琴工作正常...它正在改變jQuery的,使用Javascript和jQuery –
變化'f的顏色($ t.is(「:contains('」+ data [d] +「')」)){'to'f($ t.is(「:containsIN('」+ data [d] +「')」) ){' –