Created
May 7, 2013 15:25
-
-
Save DaveGoosem/5533481 to your computer and use it in GitHub Desktop.
jQuery DOM Traversal
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
//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. | |
$("#vacations li").first().next().next() //would be the 3rd <li> | |
//returns the 'parent' of the slelected DOM item | |
$(".featured").parent() | |
//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