JavaScript Reference/Javascript Methods/appendChild
"appendChild()" Example
<source lang="javascript">
<html> <body> <script language="javascript"> function function1(){
var myElement = document.createElement("document.all.myBody.appendChild(myElement);
} </script> <body id="myBody"><button onclick="function1();">Append child</button></body> </body> </html>
</source>
"appendChild()" is applied to
<source lang="javascript">
+----------------+--------------------------------------------------------------+ | Applied_To |<a> <acronym> | | |<address> <applet> | | |<area> attribute | | | <base> | | |<basefont> |
| ||| |<body>
| | |<button>| | | | | |
| |<col> | | |<colgroup> <comment> | | |
| | | <dir> ||
| |
- | | |<fieldset> | | |<form> <frame> | | |<frameset> <head> | | |<hn>
|| |<html> | | |<iframe> <img> | | |<input type="button"> <input type="checkbox"> | | |<input type="file"> <input type="image"> | | |<input type="password"> <input type="radio"> | | |<input type="reset"> <input type="submit"> | | |<input type="text"> | | |<isindex> | | |<label> <legend> |
| |- <link> | | |<listing> <map> | | |<marquee> <menu> | | |<meta> <noframes> | | |<noscript> <object> | | |
<optgroup> | | |<option>
| | |<param> <plaintext> | | |
| | || | |<script> <select> | | | | | || | |<style> | | || | |<tbody>
| | |<textarea> <tfoot> |
| |<thead> | | |<title> | | | | | | | | |<xmp> | +----------------+--------------------------------------------------------------+ </source>
"appendChild()" Syntax, Parameters and Note
<source lang="javascript"> Note: Appends a child element to the HTML element.
Syntax:
attributeName.appendChild(param1) // IE only document.getElementById("elementID").appendChild(param1) document.all.elementID.appendChild(param1) // IE only
Parameters: param1 Required; the element to append.
</source>