JSFiddle - React, Tailwind, and code Playground
by David Buzatto
HTML
<button id="btnStart"/>Start</button>
<button id="btnStop"/>Stop</button>
JavaScript
// start and stopping
var obj = {
size: 5,
animationsId: [],
start: function() {
for ( var i = 0; i < this.size; i++ ) {
this.animationsId[i] = setInterval( function() {
console.log( "aaa" );
}, 500 );
}
},
stop: function() {
for ( var i = 0; i < this.size; i++ ) {
clearInterval( this.animationsId[i] );
}
}
};
$( "#btnStart" ).click(function(){
obj.start();
});
$( "#btnStop" ).click(function(){
obj.stop();
});