2024-04-12 10:31:49 -04:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<p>Click the button to get the tag names of the body element's children.</p>
|
|
|
|
|
|
|
|
<button onclick="myFunction()">Try it</button>
|
|
|
|
|
|
|
|
<p id="demo"></p>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
function myFunction() {
|
|
|
|
var c = document.body.children;
|
|
|
|
var txt = "";
|
|
|
|
var i;
|
|
|
|
for (i = 0; i < c.length; i++) {
|
|
|
|
txt = txt + c[i].tagName + "<br>";
|
|
|
|
}
|
|
|
|
|
|
|
|
console.assert(txt === '#text<br>P<br>#text<br>BUTTON<br>#text<br>P<br>#text<br>SCRIPT<br>#text<br>#text<br>', txt);
|
|
|
|
}
|
|
|
|
|
|
|
|
console.error('document.body.children');
|
|
|
|
myFunction();
|
2024-06-01 07:30:03 -04:00
|
|
|
console.exit();
|
2024-04-12 10:31:49 -04:00
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|