How to automatically detect an HTML tag if it contains a certain attribute like data-wow-delay? This is from wow.js.
What I want to do is that if an HTML tag contains the said attribute, it will automatically add the classes wow bounce in the tag.
Example
HTML
<h1 data-wow-delay="0.2s">
sample
</h1>
JS (this is where I am at lost, not sure how to start it)
Outcome should be something like this when inspected
<h1
class="wow bounce"
data-wow-delay="0.2s"
>
sample
</h1>
Note: there are a lot of different HTML tags that use this attribute.
Use
Element.hasAttribute()to check whether the element contains the specified attribute:Alternatively, you can use
querySelectorAlland the CSS attribute selector to select all elements with the attribute: