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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.