I have this button that, when it loads, I set "animated flash" as a class so that it does the "flash" animation of animate.css. The problem I have is when I put the class back on when I click the button, it doesn't pick up the animation. Any way to fix this?
var elemento = document.getElementsByTagName("button")
elemento[0].setAttribute("class","animated flash")
function handleOnClick(e) {
console.log("button clicked");
const button = e.target;
button.setAttribute("class", "animated flash");
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
<button onclick="handleOnClick(event)"> myAnimatedButton </button>
You should remove the class and add it back.
The code would be something like this: