0
我有我的頁面上的表,它上面的過濾文本框的作品太棒了,使用下面的JQuery:復位按鈕
$("#searchInputCompanies").keyup(function() {
//split the current value of searchInput
var data = this.value.split(" ");
//create a jquery object of the rows
var jo = $("#cBody").find("tr");
if (this.value == "") {
jo.show();
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.text().toLowerCase().indexOf(data[d].toLowerCase()) > -1) {
return true;
}
}
return false;
})
//show the rows that match.
.show();
$('#selectAllCompanies').prop('checked', '');
}).focus(function() {
this.value = "";
$(this).css({
"color": "black"
});
$(this).unbind('focus');
}).css({
"color": "#C0C0C0"
});
我怎樣才能建立一個復位過濾按鈕爲了這?
'$('#companyReset')。on(「click」,function(){$(「#searchInputCompanies」).val('' );});'確實清除了過濾器框,但它不會觸發過濾器運行(並因此清除) – PKD 2014-11-21 22:42:33
嗯,這很奇怪,但沒有問題:'$(「#resetAction」)。on(「whatEventYouWant」,function(){0} ); //或'keyup'如果你沒有改變事件 });'編輯主要答案。 – kappaallday 2014-11-21 22:43:59
輝煌。謝謝。 – PKD 2014-11-21 22:45:21