JavaScript DHTML/Node Operation/appendChild — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 13:02, 26 мая 2010
"appendChild()" Example
<source lang="html4strict">
<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>
Append text node to paragraph tag
<source lang="html4strict">
<html> <head>
<title>Location</title> <script type = "text/javascript"> function showProps() { var body = document.getElementsByTagName("body")[0]; for (var prop in location) { var elem = document.createElement("p"); var text = document.createTextNode(prop + ": " + location[prop]); elem.appendChild(text); body.appendChild(elem); } } </script>
</head> <body onload="showProps()"> </body> </html>
</source>