Working with DOM in JavaScript
Working with DOM
Each element present in the DOM has a set of properties and methods which are used to provide information about their relationship in the DOM.
Some of these properties are:-
1. childNodes:-
element.childNodes returns an array of an element's child nodes.
2. firstChild:-
element.firstChild returns the first child node of an element.
3. lastChild:-
element.lastChild returns the last child node of an element.
4. hasChildNodes:-
element.hasChildNodes returns true if an element has any child nodes, otherwise false.
5. nextSibling:-
element.nextSibling returns the next node at the same tree level.
6. previousSibling:-
element.previousSibling returns the previous node at the same tree level.
7. parentNode:-
element.parentNode returns the parent node of an element.