Crear dinamicamente divs - Javascript:
//create a div element
const div = document.createElement('div');
//add a class to the div
div.classList.add('my-div');
//add an id to the div
div.id = 'my-div';
//add a text node to the div
div.appendChild(document.createTextNode('Hello World'));
//add the div to the body
document.body.appendChild(div);
Oldest comments (0)