mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
[assert] document.body.childNodes
This commit is contained in:
parent
5f8898b2a2
commit
974429611c
32
test/ecmascript/assert/document.body.childNodes.html
Normal file
32
test/ecmascript/assert/document.body.childNodes.html
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<!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>
|
Loading…
Reference in New Issue
Block a user