set margin from javascript code example
Example: js add margin with variable
document.getElementsByClassName('player')[0].style.marginTop = playerPosition+"px";
document.getElementsByClassName('player')[0].style.marginTop = playerPosition+"px";