var $buttons = $('button.star-button') var index = 0 var timer = window.setInterval(function(){ if(index >= $buttons.length){ window.clearInterval(timer); }else{ $buttons[index++].click(); } }, 1000)