How to check if an element in DOM has a specific attribute using JavaScript?
Originally posted here!
To check if the element has a specific attribute in JavaScript, you can use the hasAttribute() method in the element.
Let's say you have an h1 element with custom attribute data-color="red" like this,
<h1 data-color="red">Hea...
melvingeorge-me.hashnode.dev2 min read