HTML DOM traversal using jQuery
jQuery provides many methods to traverse the elements.
- <element>.first() – Gets the first element matching selector
- <element>.children() – Gets the child element of selected element
- <element>.siblings() – Gets the sibling elements of selected element
- <element>.parent() – Gets the parent of selected element
- <element>.prev() – Gets the previous sibling of selected element
- <element>.next() – Gets the next sibling of selected element
- <element>.remove() – Deletes the selected element
- <element>.filter(“.xyz”) – returns all elements that have class .xyz
- <element>.find(“.xyz”) – returns all child elements that have class .xyz
- <element>.closest(“.xyz”) – returns closest element that have class .xyz
Recent Comments