1
我想根据数据属性筛选表格,而不是根据td
标记中的值筛选表格。带有jQuery数据属性的筛选器表
的问题是,我不能得到它的工作,因为我总是得到这个错误:
Uncaught TypeError: Cannot call method 'match' of undefined
$(document).ready(function(){
var elemens = $("td")
searchInput = $("#search")
searchInput.on('keyup',function(){
elemens.each(function(){
var re = new RegExp(searchInput.val(), 'gi');
if($(this).data('gui').match(re) === null)
{
$(this).parent('tr').hide();
}else{
$(this).parent('tr').show();
}
});
});
});
我的小提琴: http://jsfiddle.net/T57ba/3/
感谢,我知道我有TD和TR犯的错,但你是什么意思是。数据()会进行类型转换? – intelis
@ user1141356 http://api.jquery.com/data/#data-html5 – Musa
哦,我明白了,谢谢 – intelis