3 Ways To Create HTML Element In JavaScript

Using Just createElement() Create a div HTML Element in JavaScript by calling the createElement() method on the document object. This method takes an argument which will be the HTML Element. In this case…div. const box = document.createElement(“div”); box.id = “box”; document.body.appendChild(box); Assign it to the constant called box. Set the id property of box to ‘box‘. Add it to the DOM hierarchy by calling appendChild() on the document.body object with an argument box. Let’s […]

Read More