how to give a div tag a unique id using javascript
问题 I'm able to make a div tag using the document.createElement('div') However i do not know how to give it a unique id. can anyone help me with this. I know how to do it using innerHTML however it very cumbersome. (I heard it not a good way of creating a layout.) 回答1: Understanding unique as an ID that must not get mixed up with any other ID's in the markup, the easiest way to go is to get the local timestamp. As shown here: let div = document.createElement("div"); // With old JS syntax div.id =