i have a list of images which i am getting through ajax and then using jquery $.each() i loop through the images and display a image one after the other after an interval of one second. I want the user to be able click on a stop button and so that the user can stop at a particular image if he wants to. So i need to dynamically exit $.each() when the user clicks on the stop button. Is it possible to do it?
相关问题
- 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
should do it.
Use
return false;
between each loop.You can use
return false
to break out ofeach()
loops early.Example:
Source: http://api.jquery.com/each/
http://api.jquery.com/each/
To break out of an
each()
loop you would:So your button could set a variable when clicked that the each loop checks each pass, then returns false when the variable is set.
http://api.jquery.com/each/