Advertisement
Online Test Banks
Score higher
See Online Test Banks
eLearning
Learning anything is easy
Browse Online Courses
Mobile Apps
Learning on the go
Explore Mobile Apps
Dummies Store
Shop for books and more
Start Shopping

Selecting Elements with jQuery

Part of the jQuery For Dummies Cheat Sheet

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 By Use This
Element type (for example, <img>) $("img")
All elements $("*")
ID (for example, id="thisIsTheID") $("#thisIsTheID")
Class (for example, class="someClass") $(".someClass")
Order (for example, the first or last <img> element) $("img:first")
$("img:last")
Attribute, (for example, to get the length attribute of <img>) $("img[height]").length
Parent (for example, the parent of <div>) $("div:parent")
Child (for example, the first or last child of <div>) $("div:first-child")
$("div:last-child")
blog comments powered by Disqus
Advertisement
Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win an iPad Mini. Enter to win now!