DEV Community


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.

Discussion (1)

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');