A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/dom/Node/appendChild below:

appendChild ยท WebPlatform Docs

appendChild Summary

Appends an element as a child to the object.

Method of dom/Nodedom/Node

Syntax
var appendedChild = node.appendChild();
Parameters newChild
Data-type
DOM Node

The child to append.

Return Value

Returns an object of type DOM NodeDOM Node

The appended child.

Examples

This example uses the appendChild method to add an item to an unordered list.

<!doctype html>
<script>
function fnAppend(){
   var oNewNode = document.createElement("LI");
   oList.appendChild(oNewNode);
   oNewNode.innerText="List node 5";
}
</script>
<body>
<ul id = oList>
<li>List node 1</li>
<li>List node 2</li>
<li>List node 3</li>
<li>List node 4</li>
</ul>
<input
   type = "button"
   value = "Append Child"
   onclick = "fnAppend()" />
</body>
Usage
 Use this method to append elements to the end of the childNodes collection.
Notes

To display new elements on the page, you must append them within the body element. For example, the following syntax demonstrates how to add a div element to the body.

var oDiv=document.createElement("DIV");
document.body.appendChild(oDiv);

This method is accessible at run time. If elements are removed at run time, before the closing tag is parsed, areas of the document might not render. Windows Internet Explorer 9. Exceptions are only supported when webpages are displayed in IE9 Standards mode.

Related specifications
DOM Level 3 Core
Recommendation
Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4