public
Created

JQuery Selectors

  • Download Gist
selectors.html
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
<!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>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.