Tuesday, 23 July 2013

Jquery Selectors Example Part I

Selector
Example
Description
*
$("table *")
Select All Elements.
#id
$("#name")
Selected element with id="name".
.class
$(".name")
Selected elements with class="name".
tag
$("p")
Selected All p elements.
:input
$(":input")
selected All input elements
:text
$(":text")
selected All input elements with type="text"
:button
$(":button")
selected All input elements with type="button".
:password
$(":password")
selected All input elements with type="password"
:radio
$(":radio")
selected All input elements with type="radio"
:checkbox
$(":checkbox")
selected All input elements with type="checkbox".
:image
$(":image")
selected All input elements with type="image".
:file
$(":file")
selected All input elements with type="file".
:submit
$(":submit")
selected All input elements with type="submit"


jQuery Selectors

•jQuery selectors is most important aspects of the jQuery library. jQuery library allow you to select elements in your HTML document by wrapping them in $(" ") (also you have to use single quotes), which is the jQuery wrapper. Selectors are useful and required at every step while using jQuery.
•jQuery Selector Syntax
•jQuery offers a powerful set of selector operations, which can be used like wild cards to identify specific elements in a page.  

Selector 
Description
TagName
Selects all element match of given elements.
this
Selects current elements.
#ID
Selects element whose id is match of given elements.
.CLASS
Selects element whose class is match of given elements.
* 
Selects all elements in the document.