DaveGoosem
5/7/2013 - 3:25 PM

jQuery DOM Traversal

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­()