Skip to content

Instantly share code, notes, and snippets.

@DaveGoosem
Created May 8, 2013 11:06
Show Gist options
  • Save DaveGoosem/5539779 to your computer and use it in GitHub Desktop.
Save DaveGoosem/5539779 to your computer and use it in GitHub Desktop.
Traversing and Filtering
/*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