dom how to declare an element code example
Example 1: create element javascript with id
var btn = document.createElement('div');
btn.setAttribute("id", "div1");
Example 2: dom create element
var btn = document.createElement("BUTTON"); // Create a <button> element
btn.innerHTML = "CLICK ME"; // Insert text
document.body.appendChild(btn); // Append <button> to <body>