Skip to content

Instantly share code, notes, and snippets.

@greghelton
Created December 27, 2011 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greghelton/1522347 to your computer and use it in GitHub Desktop.
Save greghelton/1522347 to your computer and use it in GitHub Desktop.
JQuery Selectors
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>JQuery Selectors</title>
</head>
<body>
<p>$("p") selects all <p> elements.</p>
<p>$("p.intro") selects all <p> elements with class="intro".</p>
<p>$("p#demo") selects all <p> elements with id="demo".</p>
<p>$("ul li:first") The first <li> element of each &lt;ul></p>
<p>$("p.plan > span") The span under the paragraph having class of "plan"</p>
<p>$("body span") will returns all spans from within the body</p>
<p>$("body > span") the direct descendent selector will return only spans directly the body tag</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment