can you add new html element using javascript code example

Example 1: 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

Example 2: how to add javascript in html

<script src="script.js"></script>

Example 3: js create element

var newDiv = document.createElement("div");
document.body.appendChild(newDiv);

Tags:

Html Example