Created
May 8, 2013 11:06
-
-
Save DaveGoosem/5539779 to your computer and use it in GitHub Desktop.
Traversing and Filtering
This file contains 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
/*allows you to filter SOME of a given element with simlar components | |
based upon what those some have that others don't. | |
For example: if you had | |
<ul> | |
<li class="vacation onsale"></li> | |
<li class="vacation onsale"></li> | |
<li class="vacation"></li> | |
<li class="vacation"></li> | |
</ul> | |
*/ | |
//this would allow you to do something with only the first 2 of these list items. | |
filter('.onsale') | |
/* | |
Using 'on() function, you can be more specific about what you target such as, if you had: | |
<div class="tour"> | |
<button class="b1" text="save" /> | |
</div> | |
along with a heap of other markup... | |
*/ | |
//this would allow you to only target 'buttons' within the 'tour' class | |
$(document).ready(function(){ | |
$('.tour').on('click', 'button', function(){ | |
//<do stuff> | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment