Created
January 27, 2012 09:18
-
-
Save scopevale/1687919 to your computer and use it in GitHub Desktop.
jsFiddle/Gist demo - jQuery selectors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="container"> | |
<div id="sub1"> | |
<div id="sub2"> | |
<div id="sub3"> | |
<div id="sub4"> | |
<ul> | |
<li>One</li> | |
<li>Two</li> | |
<li>Three</li> | |
<li>Four</li> | |
<li>Five</li> | |
</ul> | |
<div id="sub5"> | |
<div id="sub6"> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
<p><button id="button1">Run 1</button></p> | |
<p><button id="button2">Run 2</button></p> | |
<p><button id="button3">Run 3</button></p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
$('#button1').click(function() { | |
$('#sub3').css({border: '2px solid red'} ); | |
}); | |
$('#button2').click(function() { | |
$('#sub6').parents('div[id$="2"]').css({border: '4px solid green'}).append('Hi I\'m #sub2'); | |
}); | |
$('#button3').click(function() { | |
$('#sub4 ul li').each(function (i) { | |
console.log(i); | |
if ($(this).text() === 'Three') { | |
$(this).css({ border: '1px solid blue'}); | |
} | |
}); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: jsFiddle/Gist demo - setTimeout | |
description: jsFiddle demo hosted on Gist | |
authors: | |
- Gary Smith | |
title: | |
- JS Fiddle - jsFiddle/Gist integration demo - setTimeout | |
resources: | |
- /js/empty.js | |
normalize_css: yes | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://jsfiddle.net/gh/gist/jquery/edge/1687919/