Ask Your Question
3

How can the jQuery animate function be used within a set Interval?

asked 2021-10-24 11:00:00 +0000

lalupa gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-06-15 07:00:00 +0000

nofretete gravatar image

To use the jQuery animate function within a setInterval, you can simply call the animate function inside the setInterval function with the desired time interval as the first argument. For example:

setInterval(function() {
  $('.element').animate({marginLeft: '+=50px'}, 'slow');
}, 1000);

This code will animate the selected element by increasing its left margin by 50 pixels every second. You can adjust the animation properties as needed, and change the time interval to speed up or slow down the animation.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-10-24 11:00:00 +0000

Seen: 10 times

Last updated: Jun 15 '21