gpt4 book ai didi

javascript - jQuery 列表过滤器不起作用(未捕获的类型错误 : Cannot read property '3' of undefined)

转载 作者:行者123 更新时间:2023-12-02 19:25:48 27 4
gpt4 key购买 nike

我正在运行 jQuery 1.8.0.min.js

当我开始在输入框中输入内容以过滤列表时,没有任何反应,并且在 Chrome 调试器中出现以下错误:

未捕获类型错误:无法读取未定义的属性“3”

指向行:

jQuery.expr[':'].Contains = function (a, i, m) {
return (a.textContent || a.innerText || "").toLowerCase().indexOf(m[3].toLowerCase()) >= 0;
};

代码:

(function ($) {
jQuery.expr[':'].Contains = function (a, i, m) {
return (a.textContent || a.innerText || "").toLowerCase().indexOf(m[3].toLowerCase()) >= 0;
};
function listFilter(list) {
var input = $('#classroomSearch');
$(input)
.change(function () {
var filter = $(this).val();
if (filter) {
$(list).find("a:not(:Contains(" + filter + "))").parent().slideUp();
$(list).find("a:Contains(" + filter + ")").parent().slideDown();
} else {
$(list).find("li").slideDown();
}
return false;
})
.keyup(function () {
$(this).change();
});
}
$(function () {
listFilter($("#filterList"));
});
}(jQuery));

最佳答案

jQuery.expr[":"].contains = jQuery.expr.createPseudo(function(arg) {
return function( elem ) {
return jQuery(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
};
});

我将其更改为上面的内容,现在可以使用了。

在这里找到它:https://github.com/nakajima/jquery-livesearch/issues/5

关于javascript - jQuery 列表过滤器不起作用(未捕获的类型错误 : Cannot read property '3' of undefined),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12060440/

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