[英]finding element by title in sortable - jquery
我正在编码两个互相连接的可排序元素面板。 在其中之一中,我通过在键盘输入过程中将其标题与匹配来输入搜索输入以查找仍然存在的内容...
这是我的代码
$('#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
检查属性是否未定义:
例如:
if ( typeof $(this).attr("title") !== 'undefined' ) {
// Do Stuff
}
else {
// Do Something else
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.