var mgr = -50, els = document.getElementsByClassName('element'); [].forEach.call(els, function(el,i){ if(i) mgr+=50; el.style.marginLeft = mgr+'px'; });