childElementCount property is used to return the total count of the child elements within the element.
var count = element.childElementCount;
Example 1 - Get total number of attributes present
- 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).
- Using the childElementCount property, we are getting the total number of child elements and displaying it (alert (attr.childElementCount)).