+ 1
How to start a SVG animation with a click of a button?
this SVG animation : https://code.sololearn.com/WvdziSo2e72X/?ref=app
6 Answers
+ 2
Thats one dirty way to do so :
window.onload = function() {
document.querySelector('.first').addEventListener('click', function() {
var elements = document.querySelectorAll('animate');
var repeat = 150;
if (elements[0].getAttribute('repeatCount') != 0) {
repeat = 0;
}
for (var i = 0; i < elements.length; i++) {
elements[i].setAttribute('repeatCount', repeat);
}
}, false);
}
Click on your name to start/stop the animation
+ 2
I am not an expert in html, but make a function in js that starts the animation and the activate it when the btn is clicked.
+ 1
with the onclick attribute
+ 1
Feichtinger Andreas how?
0
write a a js function that sets the repeatcounter
0
Thank you, Alexander Schwirjow!!