Skip to content

Instantly share code, notes, and snippets.

@DaveGoosem
Created May 7, 2013 15:25
Show Gist options
  • Save DaveGoosem/5533481 to your computer and use it in GitHub Desktop.
Save DaveGoosem/5533481 to your computer and use it in GitHub Desktop.
jQuery DOM Traversal
//returns all instances of the selector within find();
$("#vacations").find(".america");
//returns only the first of all similar DOM items
$("#vacations li").first();
//returns only the last of all similar DOM items
$("#vacations li").last();
//returns the 'next' similar DOM item to the one you previsouly specified.
$("#vacatio­ns li").­first().ne­xt().next(­) //would be the 3rd <li>
//returns the 'parent' of the slelected DOM item
$(".featur­ed").paren­t()
//returns all 'child' DOM items of the item selected.
$("#tours"­).children­()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment