How can i create unique id for html elements
6/3/2020 10:20:09 AMAsef Dian🇧🇩
2 AnswersNew Answer
Asef Dian🇧🇩 Hey. Of course you can do that. Here's the solution : <script src="https://cdnjs.cloudflare.com/ajax/libs/node-uuid/1.4.8/uuid.js"></script> Include this in your head tag. Now you can make a unique id each time you run the code. Like so : const id = uuid(); Now use this 'id' as your element's id. That's all :))
uuids are huge, why would you want to create one as the id of an html element? It isn't exactly easy to write... var element = document.getElementById(af2b32ac-6913-4373-9ad9-edd05cae63b1); and how are you going to know what the id is anyway? The uuids will change each time the program runs.