DEV Community

AjayMalhotra
AjayMalhotra

Posted on

3

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

Sentry image

See why 4M developers consider Sentry, β€œnot bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay