Categories
JavaScript Answers

How to get an element’s id with JavaScript?

Spread the love

To get an element’s id with JavaScript, we use the id property.

For instance, we write

const id = myDOMElement.id;

to get the myDOMElement‘s ID with the id property.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *