generate random string for div id

后端 未结 12 748
旧时难觅i
旧时难觅i 2020-12-04 17:03

I want to display YouTube videos on my website, but I need to be able to add a unique id for each video that\'s going to be shared by users. So I put this toget

12条回答
  •  孤街浪徒
    2020-12-04 17:54

    Here is the reusable function to generate the random IDs :

    function revisedRandId() {
         return Math.random().toString(36).replace(/[^a-z]+/g, '').substr(2, 10);
    }
    

    // It will not start with the any number digit so it will be supported by CSS3

提交回复
热议问题