Milan Koyš Milan Koyš - 10 months ago 51
CSS Question

How can i add to value not set value

How can add an value of 50 not set the left attribute left to 50?

document.getElementById("myDiv").style.left = "50px";

I am trying to get a smooth animation effect for my picture slider.

Answer Source

You could parse the value and add some value to it.

document.getElementById("myDiv").style.left = 
    (parseInt(document.getElementById("myDiv").style.left, 10) + 50) + 'px';