Compare Revisions

document.createElement

Revision 67609:

Revision 67609 by Ptak82 on

Revision 67610:

Revision 67610 by Jovemsabio on

Title:
document.createElement
document.createElement
Slug:
DOM/document.createElement
DOM/document.createElement
Tags:
DOM, Gecko, "Gecko DOM Reference"
DOM, Gecko, "Gecko DOM Reference"
Content:

Revision 67609
Revision 67610
n34      This snippet creates a new <div> and inserts it beforn34      This creates a new <div> and inserts it before the el
>e the element with id "preface":>ement with id "Mydiv":
t36    <pre class="eval">t36    <pre>
37var preface = document.getElementById("preface");37&lt;html&gt;
38&lt;head&gt;
39&lt;title&gt;||Working whith elements||&lt;/title&gt;
40&lt;/head&gt;
41&lt;script language="javascript"&gt;
42var mydiv =false;
43var div = false;
44 
45function init(){
46   mydiv = document.getElementById("Mydiv");
38var div = document.createElement("div");47   div = document.createElement("div");
39document.insertBefore(div, preface);48   document.body.insertBefore(div, mydiv);
49   div.innerHTML="&lt;h1&gt;Hi there!&lt;/h1&gt;";
50}
51 
52&lt;/script&gt;
53 
54&lt;body onLoad="init()"&gt;
55 
56&lt;div id='Mydiv'&gt; The text above has been created dynamicall
 >y &lt;/div&gt;
57 
58&lt;/body&gt;
59&lt;/html&gt;

Back to History