var oTil=document.getElementById("title") var i=20; oTil.onclick=function(){ alert(i) setInterval(function(){ this.style.left='300px'; i++},300 ) }