📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials jQuery in Practice Filter and Map

Filter and Map

5 min read
filter() narrows a set to elements matching a selector or callback. not() removes matching elements. is() returns true or false — useful in conditionals like if ($(this).is('.active')) inside event handlers.

Filtering and Mapping

// Filter elements
$('li').filter('.active');          // by selector
$('li').filter(function() {
  return $(this).text().length > 5;
});

// Map elements to array
const texts = $('li').map(function() {
  return $(this).text();
}).get();

// not() — exclude elements
$('li').not('.done').css('color', 'blue');