I am trying to filter a table based on data attribute, instead on value inside the td tag.
The problem is, that I can't get it to work, because I always get this error:
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();
}
});
});
});
My Fiddle: http://jsfiddle.net/T57ba/3/