gpt4 book ai didi

javascript - jQuery 表格过滤器

转载 作者:行者123 更新时间:2023-11-28 18:07:11 24 4
gpt4 key购买 nike

我已经创建了一个表,但现在能够以某种方式过滤该行。它给我错误,因为无法读取属性分割。这是我的fiddle的链接文件。任何帮助都会很棒。提前致谢。

$("#crudtable_filter").keyup(function () {
//split the current value of searchInput
var data = this.value.split(" ");
//create a jquery object of the rows
var jo = $("#crudtable").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.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"
});

最佳答案

工作 fiddle :http://jsfiddle.net/sofqjbrg/3/

说明:

为了获取触发事件的元素的值,您需要使用$(event.target).val()

$(event.target)$(this)的区别请引用Difference between $(this) and event.target?

PS:您的焦点事件注册到了错误的元素。

关于javascript - jQuery 表格过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42359339/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com