add id in javascript code example
Example 1: javascript change attribute
var element = document.getElementById("elemId");
element.setAttribute("attributeName", "value");
Example 2: create element javascript with id
var btn = document.createElement('div');
btn.setAttribute("id", "div1");
Example 3: add id to element javascript
myPara.setAttribute("id", "id_you_like");
Example 4: set attribute javascript
Element.setAttribute(name, value);
Example 5: javascript add id to element
myelement.id = yourid;