You are on page 1of 1

JQuery selectors

JQuery Selector
$(*)
$(.myClass)
$(element)
$(#myid)

Description
Select all the elements in the
document.
Selects all the elements to which the
CSS class myclass has been assigned
Selects all the elements of the type
element
Selects the element with the ID of
myid

jQuery selectors are greedy, meaning they select as many elements as they
can in the HTML DOM. One exception to this is the $('#id') selector, which
selects the element with the specified id attribute value.
Element id values are meant to be unique in HTML although a common error
in web applications is to generate duplicate ID values from data objects.
When this happens, you can usually expect to get the first element that has
the specified id value, but you shouldnt rely on this behavior because it is
dependent on the behavior of the users browser.
JQuery document ready function short cut
$(function( ){ // all javascript code });

You might also like