var c=0 var t $foo = $('#foo') function timedCount() { $foo.html(c) c=c+1 $foo.addClass('big') $foo.on('transitionend', function (e){ console.log(1) var style = getComputedStyle(e.target) if (style.scale == '1.5'){ $foo.removeClass('big').addClass('small') $foo.on('transitionend', function (e) { var style = getComputedStyle(e.target) if(c<=10&&style.scale == '1'){ $foo.removeClass('big') $foo.removeClass('small') timedCount() } else{ console.log('123') } }) } }, 500) } $('#btn').on('click',function(){ timedCount() })