js add margin with variable code example
Example 1: js add margin with variable
document.getElementsByClassName('player')[0].style.marginTop = playerPosition+"px";
Example 2: js add margin with variable
var players = document.getElementsByClassName('player');
for(var i = 0; i < players.length; i++)
players[i].style.marginTop = playerPosition+"px";