In this lecture I’ll be making a virtual DOM object within Javascript. Then I’ll tell the DOM to add the relevant element using the information from our virtual DOM object. This will allow me to produce an element from Javascript.
This tutorial is brought to you by http://www.avelx.co.uk/ – Coding tutorials to help you grow.
Original source
10 responses to “Javascript Tutorial | Create & Append DOM Element's”
var d = {};
d.make = document.createElement;
d.nest = function(parent, child) { return parent.appendChild(child); };
var divL1= d.make('div'); divL1.id='divL1'; d.nest(document.body, divL1);
var divL2 = d.make('div'); divL2 .id='divL2 '; d.nest(divL1, divL2 );
var divL3 = d.make('div'); divL3.id='divL3'; d.nest(divL2, divL3);
.
.
.
We don't need to write html – beyond the basic, empty html skeleton. We can actually write our application in javascript in a nested, outline format that somewhat mimics an html outline, for easier readability.
thank you, great material 🙂
finally! exactly what I was looking for and a good explanation
Great explanation! you are a great lecturer. Count me as one of loyal subscribers. I like this video so much. Keep it up!
I know. That's how they pronounce the letter 'h' in England (and parts of Europe I believe) "hache". Makes since considering what words sound like that use that letter 'h' right?
Toda vez que faço um appendChild() via click o DOM adiciona uma replica do elmento. Como faço para corrigir isso? Obrigado.
please check out this JS-Basic DOM Project
https://youtu.be/xuubcO-Le0U
How would i insert an array instead of insert text?
what's hacheTML? ; )
you are awesome, leaned a lot out of your experience!