Difference between revisions of "DOM Creating content"
Jump to navigation
Jump to search
(Created page with "==Change Content== <div class='qu'> You can create a div element an set the content. We use the document method '''createElement''' and the DOM node method '''appendChild'''...") |
|||
Line 6: | Line 6: | ||
<pre class='usr'> | <pre class='usr'> | ||
let e = document.createElement('div'); | let e = document.createElement('div'); | ||
e | e.innerHTML = 'Hello'; | ||
document.body.appendChild(e); | document.body.appendChild(e); | ||
</pre> | </pre> | ||
<pre class='ans'> | <pre class='ans'> | ||
let e = document.createElement('div'); | let e = document.createElement('div'); | ||
e | e.innerHTML = 'Hello world'; | ||
document.body.appendChild(e); | document.body.appendChild(e); | ||
</pre> | </pre> | ||
</div> | </div> |
Revision as of 15:14, 10 August 2021
Change Content
You can create a div element an set the content.
We use the document method createElement and the DOM node method appendChild
let e = document.createElement('div'); e.innerHTML = 'Hello'; document.body.appendChild(e);
let e = document.createElement('div'); e.innerHTML = 'Hello world'; document.body.appendChild(e);