Hackerss.com

Hackerss.com is a community of amazing hackers

Hackerss is a community for developers, data scientitst, ethical hackers, hardware enthusiasts or any person that want to learn / share their knowledge of any aspect of digital technology.

Create account Log in
hackerss
hackerss

Posted on

Crear dinamicamente divs in Javascript

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);

Enter fullscreen mode Exit fullscreen mode

Top comments (0)