I'm trying to pause a CSS animation with an HTML button click, using JS to carry out the pause. So far I've tried to change the animation state using JS but it isn't working - the animation plays through and the button seems to have no effect.
Here's my JS snippet:
var sun = document.getElementById("sun");
var sky = document.getElementById("sky");
var pauseBtn = document.getElementById("pauseBtn");
function pauseAnimation(){
if((pauseBtn.clicked) == true){
sun.style.animationPlayState("paused");
sky.style.animationPlayState("paused");
}
}
h2:after {
content : ' no css!';
color : red;
}
<h2>no HTML</h2>
Can share more code if necessary, any tips based on what you see with the JS?