Selecting Elements with jQuery

jQuery allows you to select elements in a Web page with ease. You can find anything you want in a page and then use jQuery to add special effects, react to user actions, or show and hide content inside or outside the element you have selected. All these tasks start with knowing how to select an element. Here’s a handy list you can use to select almost anything on your Web page.







































To Select ByUse This
Element type (for example, class="code"><img>)$("img")
All elements$("*")
ID (for example, class="code">id="thisIsTheID")$("#thisIsTheID")
Class (for example, class="code">class="someClass")$(".someClass")
Order (for example, the first or last class="code"><img> element)$("img:first")class="code">

$("img:last")
Attribute, (for example, to get the length attribute of class="code"><img>)$("img[height]").length
Parent (for example, the parent of class="code"><div>)$("div:parent")
Child (for example, the first or last child of class="code"><div>)$("div:first-child")class="code">

$("div:last-child")



dummies

Source:http://www.dummies.com/how-to/content/selecting-elements-with-jquery.html

No comments:

Post a Comment