【发布时间】:2012-12-12 11:47:50
【问题描述】:
我正在尝试根据数据属性过滤表,而不是根据 td 标记内的值。
问题是,我无法让它工作,因为我总是收到这个错误:
未捕获的类型错误:无法调用未定义的方法“匹配”
$(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/
【问题讨论】: