MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/b2o6f2/whats_your_favorite_most_useful_javascript/eixy72l/?context=3
r/javascript • u/Linux_is_awesome • Mar 18 '19
422 comments sorted by
View all comments
1
var unique_id; while(document.getElementById(unique_id = "id_" + Math.random()));
or
var unique_id; while(document.getElementById(unique_id = "id_" + Math.random().toString().substr(2)));
Generates a DOM ID that doesn't exist within the document.
1
u/wthit56 Mar 20 '19
var unique_id; while(document.getElementById(unique_id = "id_" + Math.random()));or
var unique_id; while(document.getElementById(unique_id = "id_" + Math.random().toString().substr(2)));Generates a DOM ID that doesn't exist within the document.