How to Get and Set the Value of a Data Attribute with JavaScript

How to get and set the value of the `data-id` attribute of an element with JavaScript.

ByJohn Au-Yeung
Published on

Enjoyed this article?

Share it with your network to help others discover it

Promote your content

Reach over 400,000 developers and grow your brand.

Join our developer community

Hang out with over 4,500 developers and share your knowledge.