mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-03 08:07:17 -05:00
29 lines
664 B
HTML
29 lines
664 B
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<body>
|
|
|
|
<ul id="myList">
|
|
<li>Coffee</li>
|
|
<li>Tea</li>
|
|
</ul>
|
|
|
|
<p>Click the button to see if the ul element has any child nodes.</p>
|
|
|
|
<button onclick="myFunction()">Try it</button>
|
|
|
|
<p>Try removing the child nodes of the list element, and the result will be false instead of true.</p>
|
|
|
|
<p><strong>Note:</strong> Whitespace inside a node is considered as text nodes, so if you leave any white space or line feeds inside an element, that element still has child nodes.</p>
|
|
|
|
<p id="demo"></p>
|
|
|
|
<script>
|
|
function myFunction() {
|
|
var list = document.getElementById("myList").hasChildNodes();
|
|
window.alert(list);
|
|
}
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|