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

Applying Basic jQuery Selectors

$("*"); //selects all elements $(".myClass"); //selects elements with class="myClass" $("#myDiv"); //selects the element with id="myDiv" $("div"); //selects <div> elements $("div, span, p"); //selects <div>, <span>, and <p> elements $("div.myClass"); //selects <div> elements with class="myClass"

The most commonly used selectors are the basic ones. The basic selectors focus on the ID attribute, class attribute, and tag name of HTML elements. Table 4.1 lists some examples to show you how to define some of the basic selectors.

Image

Table 4.1 Examples of Using Basic jQuery Selectors

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