JavaScript Tutorial/DOM Node/createElement — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 11:24, 26 мая 2010
Create an element from document
<source lang="javascript">
<html> <head> <title>appendChild() Example</title> <script type="text/javascript">
function appendMessage() { var oNewP = document.createElement("p"); var oText = document.createTextNode("www.wbex.ru"); oNewP.appendChild(oText); document.body.appendChild(oNewP); }
</script> </head> <body onload="appendMessage()">
Hello World!
</body> </html></source>
Create Paragraph element and set the text
<source lang="javascript">
<html> <head> <title>appendChild() Example</title> <script type="text/javascript">
function appendMessage() { var oNewP = document.createElement("p"); var oText = document.createTextNode("www.wbex.ru"); oNewP.appendChild(oText); document.body.appendChild(oNewP); }
</script> </head> <body onload="appendMessage()">
Hello World!
</body> </html></source>