view more software Tips and Tricks
Updated: 06/15/2013 04:06 AM
Author: Shiju Mathews
Chapter 5 - Selectors in jQuery
selectors allow you to select and manipulate HTML elements. jQuery selectors are used access HTML elements based on their id, classes, types, attributes, values of attributes etc.
All selectors in jQuery start with the dollar sign and parentheses: $().
Selecton by element:element selector selects elements based on the element name.
You can select all elements on a page as : $("span")
#id SelectorThe jQuery #id selector uses the id attribute of an HTML tag to find the specific element. An id should be unique within a page, so you should use the #id selector when you want to find a single, unique element.
To find an element with a id, write a hash character, followed by the id of the element in parentheses as $("#info").
class SelectorThe jQuery class selector finds elements with a specific class name.
Download Code sample
More Examples of jQuery Selectors