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

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more