Reputation: 27
Hi I'm trying to stop this shake effect after three shake. Is it possible to use set or clearInterval on this one? Thanks in advance for your help!
function interval() {
$('#shake').effect('shake', {
times: 3
}, 100);
}
$(document).ready(function() {
var shake = setInterval(interval, 1200);
});
<div id="shake">This Text is Shaking</div>
Upvotes: 0
Views: 371
Reputation: 82251
modify interval method to:
var executedcoount=0;
function interval() {
if(executedcoount<3){
$('#shake').effect('shake', {
times: 3
}, 100);
executedcoount++;
}
}
Upvotes: 1