jQuery Selectors
Selectors are a core piece of the jQuery library. jQuery code follows this basic methodology:
Select an element.
Do something with it.
As we mentioned above, the $() is the method that you use to select elements. For $(document).ready(), we’re actually selecting the “document” and defining what to do when the ready() event fires.
You can select any element (or multiple elements) on your page. Following are three basic ways of selecting elements:
• By ID—
Matches a single element with the element ID. The ID you provide should be prefaced by a # character. For example, $("#myId") would match <div id="myId">.
• By CSS Class—
Matches all elements with the provides CSS class. The class you provide should be prefaced with a . character. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access