.has()
methodThe .has()
method in jQuery is used to filter the set of matched elements, keeping only that have a descendant that matches the selector or DOM element.
.has()
method Syntax.has(selector) .has(contained)
selector
is an expression and contained
is a DOM element to match elements against.
.has(selector)
Highlight the item that have a class selected
$('li').has('.selected').css('background','cyan');
.has(contained)
Add a red background for the item that has a <ul>
among its descendants.
$( "li" ).has( "ul" ).css( "background-color", "red" );