var x = 0; function upAndDown () { var lift = document.getElementById('lift'); lift.style.marginBottom = x +"px"; x += 50; } function lift () { timer = window.setInterval("upAndDown()", 1000); } <a href="javascript:lift()"> button </a>