Using the jQuery library and the offset () method, it seems logical to think that by writing this simple code, the element will gradually change position
for (i = 0; i < 900; i = i + .5) { $('#moving-element').offset({ top: i }) }
The browser will stop for a while and, finally, move the element to the 900px position separately from the top, the transition will not be observed. Out of curiosity, I wrote this:
for (i = 0; i < 900; i = i + .5) { $('#moving-element').offset({ top: i }); console.log(i) }
to see the console display a sequence of numbers in order, but it only shifts the item after the for loop completes.
Why is this not done gradually while executing the code?
Mg gm source share