+ 1
why var is not updating in js with setinterval .please check code below.
i have a div div which move left onclick by function move.i have set interval on function and define left in fxn but it is not updating .please help. the cide is like this. function move() { var mydiv = document.querySelector("#divid") ; posnleft = window.getComputedStyle(mydiv).getPropertyValue("left") ; console.log(posnleft); } move(); setInterval(move,1000); now if move div to right it should update value in console after 1s . but it is only repeat of 10px (as in style ) in console.
3 Réponses
+ 2
I didn't any code that move it right?
+ 1
Because you didn't update value of left selector.
+ 1
can you please explain it a little bit more.
i have move it right using js with a btn .