mirror of
https://github.com/rkd77/elinks.git
synced 2024-06-28 01:35:32 +00:00
[assert] element.appendChild
This commit is contained in:
parent
3f9af02ff6
commit
1435c2da92
30
test/ecmascript/assert/element.appendChild.html
Normal file
30
test/ecmascript/assert/element.appendChild.html
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<ul id="myList">
|
||||||
|
<li>Coffee</li>
|
||||||
|
<li>Tea</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<p>Click the button to append an item to the end of the list.</p>
|
||||||
|
|
||||||
|
<button onclick="myFunction()">Try it</button>
|
||||||
|
|
||||||
|
|
||||||
|
<p><strong>Note:</strong><br>First create an LI node,<br> then create a Text node,<br> then append the Text node to the LI node.<br>Finally append the LI node to the list.</p>
|
||||||
|
<script>
|
||||||
|
function myFunction() {
|
||||||
|
var node = document.createElement("LI");
|
||||||
|
var textnode = document.createTextNode("Water");
|
||||||
|
node.appendChild(textnode);
|
||||||
|
document.getElementById("myList").appendChild(node);
|
||||||
|
console.assert(document.getElementsByTagName("UL")[0].outerHTML === '<UL id="myList">\n <LI>Coffee</LI>\n <LI>Tea</LI>\n<LI>Water</LI></UL>', 'Water');
|
||||||
|
}
|
||||||
|
console.error('element.appendChild.html');
|
||||||
|
myFunction();
|
||||||
|
console.exit(0);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user