1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00
elinks/test/ecmascript/assert/document.body.childNodes.html

33 lines
797 B
HTML
Raw Normal View History

2024-04-12 11:06:39 -04:00
<!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();
2024-04-12 11:06:39 -04:00
</script>
</body>
</html>