Menu

How to read any attribute value using the element class name using JS?

Using the DOM function we could find the element using class name and then from that search list go to first index and get the required attribute.

document.getElementsByClassName('class_name')[0].getAttribute('id');

No comments:

Post a Comment