HTML DOM traversal using jQuery

jQuery provides many methods to traverse the elements.

  1. <element>.first() – Gets the first element matching selector
  2. <element>.children() – Gets the child element of selected element
  3. <element>.siblings() – Gets the sibling elements of selected element
  4. <element>.parent() – Gets the parent of selected element
  5. <element>.prev() – Gets the previous sibling of selected element
  6. <element>.next() – Gets the next sibling of selected element
  7. <element>.remove() – Deletes the selected element
  8. <element>.filter(“.xyz”) – returns all elements that have class .xyz
  9. <element>.find(“.xyz”) – returns all child elements that have class .xyz
  10. <element>.closest(“.xyz”) – returns closest element that have class .xyz

 

You may also like...