mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
33 lines
798 B
HTML
33 lines
798 B
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<body><!-- This is a comment node! -->
|
|
|
|
<p>Click the button get info about the body element's child nodes.</p>
|
|
|
|
<button onclick="myFunction()">Try it</button>
|
|
|
|
<p><strong>Note:</strong> Whitespace inside elements is considered as text, and text
|
|
is considered as nodes. Comments are also considered as nodes.</p>
|
|
|
|
<p id="demo"></p>
|
|
|
|
<script>
|
|
function myFunction() {
|
|
var c = document.body.childNodes;
|
|
var txt = "";
|
|
var i;
|
|
|
|
for (i = 0; i < c.length; i++) {
|
|
txt = txt + c[i].nodeName + "<br>";
|
|
}
|
|
console.assert(txt === '#comment<br>#text<br>P<br>#text<br>BUTTON<br>#text<br>P<br>#text<br>P<br>#text<br>SCRIPT<br>#text<br>#text<br>#text<br>', 'Child nodes');
|
|
}
|
|
|
|
console.error('document.body.childNodes');
|
|
myFunction();
|
|
console.exit(0);
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|