O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting Items That Contain Other Items

$("div").has("p");   //selects <div> element that has <p> descendents $("div").has("#menu");   //selects <div> element that contains   //the element that has id="menu"

The .has(selector or element) method reduces the set to those elements that have descendent elements that match the selector or contain the specified DOM element.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required