Saturday, 24 August 2013

How to filter search results based on multiple data attributes

How to filter search results based on multiple data attributes

I'm trying to search multiple data results based on inline data
attributes. However, I can only figure out how to search a single data
attribute instead of them all. How would I accomplish this?
What I have: http://jsfiddle.net/9SMZC/2/
$("input[type=text]").keyup(function () {
var filter = $(this).val();
$("a").each(function () {
if ($(this).attr("data-event-name").search(new RegExp(filter,
"i")) < 0) {
$(this).hide();
} else {
$(this).show();
matches++;
}
});
});
Thanks in Advance!

No comments:

Post a Comment