insert element with id javascript code example
Example 1: create element javascript with id
var btn = document.createElement('div');
btn.setAttribute("id", "div1");
Example 2: js add more text to element
document.getElementById("p").textContent += " This is the text from javascript.";
<p id ="p">This is the text from HTML.</p>