Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在可排序的jquery中按标题查找元素_Javascript_Jquery_Jquery Ui Sortable - Fatal编程技术网

Javascript 在可排序的jquery中按标题查找元素

Javascript 在可排序的jquery中按标题查找元素,javascript,jquery,jquery-ui-sortable,Javascript,Jquery,Jquery Ui Sortable,我正在对两个相互连接的可排序元素面板进行编码。在其中一个例子中,我将搜索输入放在键盘上,通过将标题与键盘上的进程匹配来查找仍然存在的内容 这是我的密码 $('#search-nama').keyup(function(){ var find = new RegExp($('#search-nama').val().toUpperCase()); grup_mk = $('#makul-container').find('.grup-mk'); /

我正在对两个相互连接的可排序元素面板进行编码。在其中一个例子中,我将搜索输入放在键盘上,通过将标题与键盘上的进程匹配来查找仍然存在的内容

这是我的密码

$('#search-nama').keyup(function(){
        var find = new RegExp($('#search-nama').val().toUpperCase());

        grup_mk = $('#makul-container').find('.grup-mk');
        //grup_mk = $('.grup-mk');
        $.each(grup_mk,function(i, l){
            console.log ($(this).attr("title"));
            s = $(this).attr("title").toString().toUpperCase();
            if(find.test(s)){
                $(this).show();
            }else{
                $(this).hide();
            }
        })
    });
这个功能通常不起作用。控制台显示这个

Uncaught TypeError: Cannot call method 'toString' of undefined 

检查属性是否未定义:

例如:


你确定每个
.grup mk
都有一个
title
属性吗?另外你还错过了
grup_mk
var
。另外,您最好使用camelCase for your js variable.:)
if ( typeof $(this).attr("title") !== 'undefined' ) {
  // Do Stuff
}
else {
  // Do Something else
}