Change code to filter via multiple attributes
03:41 26 May 2026

I have a filter setup using jQuery as per the snippet.

I would like to be able to filter by multiple attributes - at the moment I can only filter by the title attribute.

How would I change the code so that I can filter all 3 attributes - e.g. title, data-emoji and version attributes?

$('[data-search]').on('keyup', function(e) {
  var searchVal = $(this).val();
  var filterItems = $('[title]');
  console.log(filterItems);
  if (searchVal != '') {
    filterItems.addClass('hidden');
    $('[title*="' + searchVal.toLowerCase() + '"]').removeClass('hidden');
  } else {
    filterItems.removeClass('hidden');
  }
});
.hidden {
  display: none;
}





πŸ˜€ πŸ˜ƒ πŸ₯° 😍 πŸ‘‹ 🀚 πŸ‘Œ 🀌

javascript jquery filter