Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js create element

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
 
PREVIOUS NEXT
Tagged: #js #create #element
ADD COMMENT
Topic
Name
5+2 =