JavaScript - Object Node - The childElementCount property

In this tutorial of the childElementCount property, we will see how to use it.
It is really easy.
This method returns the number of elements of a node.


<!DOCTYPE html>
<meta charset="UTF-8">
<title>Insert title here</title>

<div id="theDiv">
    <ul id="myUl">
        <li id="li0">Hello</li>
        <li id="li1">Welcome</li>
        <li id="li2">On</li>
        <li id="li2"></li>

<script type="text/javascript">

var myElement;
myElement = document.getElementById('theDiv');

document.write('myElement.childElementCount[1] = ' + myElement.childNodes[1].childElementCount);



The result is 4, of course. smiley