0

Is there a way to change smoothly .css() with jQuery? Like changing .css("top", myValue) from 0 to 200 smoothly by counting up each step (like 0, 1, 2, 3, ..., 198, 199, 200)? I do not want to use CSS transitions. Reason (long story short): Device which shall run the site does not support transitions smoothly with "top", transformY forces a bug of the browser that's not fixed yet.

Of course I could write a loop like counting "myValue" from 0 to 200 and updating it. But I'd love if there was a jQuery-implemented way.

$("myDiv").css( "top", myValue ); // make it smooth

1
  • 1
    I think you are looking for .animate() Commented Jun 11, 2019 at 19:25

1 Answer 1

1

Try $.fn.animate (http://api.jquery.com/animate/)

$("myDiv").animate( {top: "+=200"}, duration );

(Note: its relative to the current position. so +=1 is adding 1px and -=1 is removing 1px.)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.