children property is used to return all child elements within the element.
Using this property, we can get the tags used in the child element as well as its contents.
var elem = element.children;
Example 1 - Get particular child element
- In the above example we have created a div (idDiv), it is the parent element.
- Within the parent element, we have added two child elements (div, p).
- Next by declaring children first child element is retrieved and its contents are displayed.
- innerHTML is used for displaying purpose only.