Home / AJAX

Page History: How Do I Use jQuery Selectors?

Compare Page Revisions



« Older Revision - Back to Page History - Newer Revision »


Page Revision: 2010/09/04 21:51


Problem

jQuery provides a ton of power with minimal lines of code. But how do I perform those actions or bind events to specific elements on the page?

Solution

The basic concept of jQuery is to “select some elements and do something with them”. Selecting can arguably be considered the power behind the jQuery Library. Without the ability to easily select elements from the DOM I don’t think jQuery would be the powerful tool for the DOM as it is today.

What makes jQuery so easy to select elements is its selector engine, Sizzle, and it’s easy syntax, which is based on the same syntax you would use to select elements in CSS by borrowing from CSS 1-3. jQuery also adds additional pseudo selectors to enable you to narrow your selection further. You can find out more about selectors by reviewing the complete reference Selector category on jQuery API site.

There are many different types of selectors. Let look at some examples.