<html>
<head>
<style>
div {
border: 1px solid black;
margin: 5px;
}
</style>
</head>
<body>
<p>Click the button to find out how many children the div element below has.</p>
<button onclick="myFunction()">Try it</button>
<div id="myDIV">
<p>First p element</p>
<p>Second p element</p>
</div>
<p><strong>Note:</strong> The childElementCount property is not supported in IE8 and earlier versions.</p>
<p id="demo"></p>
<script>
function myFunction() {
var c = document.getElementById("myDIV").childElementCount;
document.getElementById("demo").innerHTML = c;
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_element_childelementcount by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 03:02:17 GMT -->
</html>