Milan Koyš Milan Koyš - 1 year ago 73
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';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download