Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h1>The Element Object</h1>
<h2>The hasChildNodes() Method</h2>
<ul id="myList">
  <li>Coffee</li>
  <li>Tea</li>
</ul>
<p>Does the list above have any child nodes?</p>
<p id="demo"></p>
<p>If you remove the child nodes of the list the result will be false.</p>
<p><strong>Note:</strong> Whitespace between nodes is considered text nodes.
If you leave any white space or line feeds, the list still has child nodes.</p>
<script>
let answer = document.getElementById("myList").hasChildNodes();
document.getElementById("demo").innerHTML = answer;
</script>
</body>
</html>