Filtering methods let you refine a set of elements by selecting specific ones based on conditions.
// jQuery filtering method syntax
$(selector).filter(selector|function);
$(selector).not(selector|function);
$(selector).eq(index);
$(selector).first();
$(selector).last();
$(selector).has(selector);
Type jQuery code below to filter the list items (e.g., .filter(':even') or .eq(1)):
$('#playList li')
// Select and filter green boxes
$('#filterContainer .box').filter('.color-green');
// Exclude green boxes
$('#filterContainer .box').not('.color-green');
// Select third box using zero-based index
$('#filterContainer .box').eq(2);
// Select first and last boxes
$('#filterContainer .box').first();
$('#filterContainer .box').last();
// Select boxes containing a span element
$('#filterContainer .box').has('span');
eq() uses zero-based indexinghas() when DOM structure mattersfilter()filter() and not()