I would like to have a div that moves up and down repeatedly using jquery. In other words, the div starts at the top of some location, moves down and then moves back up and repeats this, in about a 1 second interval from going from top to bottom and 1 second back to the top. There's the slideUp and slideDown as well as animate methods but I'm not sure how to accomplish this since it needs to be in an endless loop and in javascript you must avoid such loops.
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
jQuery's animate logic can safely be called with callbacks or chained together without using setTimeout/setInterval:
Something like this should work just fine for you
Demo
use setInterval, see here: http://www.w3schools.com/js/js_timing.asp
so try this
Javascript
HTML
you may need to tweak the timings (which are in miliseconds)