====== Traverse ======
This section discusses methods that will enable you to walk the DOM, from selecting the parent to selecting the nodes that are next to the current element.
===== end( ) =====
Gets the elements in the previous chain.
a
b
Karma('div'); // div
Karma('div').add('span'); // div, span
Karma('div').add('span').end(); // div
===== children( [selector] ) =====
Selects all the children of the elements that match the selector (only if selector exists)
alert(Karma('ul').children().get()); // [ a, b, c ]
===== decendents( selector ) / find( selector )=====
Selects all the decendents of the elements that match the selector.
alert(Karma('#div').decendents('li').get()); // [ a, b, c ]
===== parent( [selector] ) =====
Selects all the parent of the elements that match the selector (only if selector exists)
alert(Karma('ul').parent().get()); // [ #demo ]
===== ancestors( [selector] ) =====
Selects all the ancestors of the elements that match the selector (only if selector exists)
alert(Karma('li').ancestors('div').get()); // [ div#demo ]
===== prev( [selector] ) =====
Selects the sibling element that appears just before the current elements that match the selector (only if selector exists)
a
b
c
alert(Karma('#hi3').prev().get()); // [ b
]
alert(Karma('#hi3').prev().prev().get()); // [ a
]
===== prevAll( [selector] ) =====
Selects the all the sibling elements that appear before the current elements that match the selector (only if selector exists)
a
b
c
alert(Karma('#hi3').prevAll().get()); // [ a
, b
]
===== next( [selector] ) =====
Selects the sibling element that appears just after the current elements that match the selector (only if selector exists)
a
b
c
alert(Karma('#hi2').next().get()); // [ c
]
===== nextAll( [selector] ) =====
Selects the all the sibling elements that appear after the current elements that match the selector (only if selector exists)
a
b
c
alert(Karma('#hi').nextAll().get()); // [ b
, c
]
===== siblings( [selector] ) =====
Selects siblings of the elements that match the selector (only if selector exists), current elements are not included
a
b
c
alert(Karma('#hi2').siblings().get()); // [ a
, c
]