0
Q:

create element javascript

var newDiv = document.createElement("div");
document.body.appendChild(newDiv);
11
var btn = document.createElement("BUTTON");
2
let myElm = document.createElement("p");	// Create a new element

myElm.innerText = 'test';		// Change the text of the element
myElm.style.color = 'red';		// Change the text color of the element

document.body.appendChild(myElm);	// Add the object to the DOM
0
var element = document.createElement("div"); //Create div
document.body.appendChild(element); //Add to bottom of <body> tag
2
var newElement = document.createElement("div"); //change div to your element
document.getElementById("myElement").appendChlid(newElement); //change myElement to your ALREADY EXISTING element
0

New to Communities?

Join the community