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. ...

Get ASP.NET 4 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.