setTimeout click
function AutoPlayLink(right,left,count) { var right=document.getElementById(right); var left=document.getElementById(left); setInterval(function() { for (i=0;i<=count;i++) { setTimeout(right.click(),10000); } for (i=0;i<=count;i++) { setTimeout(left.click(),10000); } },5000); } $(document).ready(function(){ AutoPlayLink('link_right','link_left',2); });