0% found this document useful (0 votes)
65 views1 page

jQuery Selectors Guide

JQuery selectors allow you to select elements on a page by CSS class, element type, or ID. The $(“*”) selector selects all elements, $(“.class”) selects elements with a class, $(“element”) selects elements by type, and $(“#id”) uniquely selects an element by ID. While selectors select all matching elements, $("#id") uniquely selects one. Element IDs should be unique but duplicates sometimes occur, in which case jQuery may select the first match but this behavior varies by browser. The $(function(){...}) shortcut runs code when the page is ready without attaching ready handlers.

Uploaded by

rafia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views1 page

jQuery Selectors Guide

JQuery selectors allow you to select elements on a page by CSS class, element type, or ID. The $(“*”) selector selects all elements, $(“.class”) selects elements with a class, $(“element”) selects elements by type, and $(“#id”) uniquely selects an element by ID. While selectors select all matching elements, $("#id") uniquely selects one. Element IDs should be unique but duplicates sometimes occur, in which case jQuery may select the first match but this behavior varies by browser. The $(function(){...}) shortcut runs code when the page is ready without attaching ready handlers.

Uploaded by

rafia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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