Wednesday, August 25, 2021

jQuery DOM Traversal example

Apart from using descendant, child and pseudo selector to select descendant, childrens, first, and last elements, you can also use DOM traversing to find elements in jQuery. DOM traversing is a powerful technique which you can use in place of selector and it give better performance. jQuery provides methods to go up and down in DOM tree and also to select first, last, next, prev, parent and child like methods to move around efficiently. Here are examples of using different DOM traversal method in jQuery :


1) first

2) last

3) next

4) previous

5) parent

6) children

No comments:

Post a Comment

Feel free to comment, ask questions if you have any doubt.