DEV Community

AjayMalhotra
AjayMalhotra

Posted on

Add Dynamic Id to class with jquery

Hello to all, here is the code for add dynamic to div with jquery:

$("dic.class").attr("id", "yourIdName")
Enter fullscreen mode Exit fullscreen mode

Thank you.
https://therichpost.com

Top comments (1)

Collapse
 
link2twenty profile image
Andrew Bone

You can do it with pure JavaScript too, a lot of the older jQuery syntax has made it into mainstream JavaScript now 🙂

document.querySelector('div.class').setAttribute('id', 'yourIdName');