Codelab Editor
Free Online HTML Editor
Run
Learn jQuery
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>jQuery stop() Example – Clear Queue</title> <style> body { font-family: Arial, sans-serif; padding: 2rem; background: #f5fdf7; } h2 { color: #2f855a; } #panel { width: 100px; height: 100px; background: #38b2ac; margin-bottom: 1rem; line-height: 100px; color: white; text-align: center; position: relative; } .buttons { display: flex; flex-direction: column; gap: 1rem; width: fit-content; } button { padding: 0.5rem 1rem; background: #2f855a; color: white; border: none; border-radius: 4px; cursor: pointer; margin-right: 10px; } button:hover { background: #276749; } </style> <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script> </head> <body> <h2>jQuery stop() – Clear Queue</h2> <p>This example uses <kbd>stop(true, false)</kbd> to stop the current animation and clear all queued animations, but does <strong>not</strong> jump to the end of the current animation.</p> <div id="panel">Box</div> <div class="buttons"> <button id="startAnimBtn">Start Animation</button> <button id="stopClearQueueBtn">Stop & Clear Queue</button> </div> <script> $(document).ready(function(){ $('#startAnimBtn').click(function(){ $('#panel').css({ left: 0, top: 0, width: '100px' }).animate({ left: '250px' }, 1000) .animate({ top: '80px' }, 1000) .animate({ width: '250px' }, 1000); }); $('#stopClearQueueBtn').click(function(){ // Stop current animation and clear the rest of the queue (don't jump to end) $('#panel').stop(true, false); }); }); </script> </body> </html>
Editor Commands
Ctrl
F
Find
Ctrl
G
Find Next
Ctrl
⇧
G
Find Previous
Ctrl
⇧
F
Find & Replace
Ctrl
]
Indent Code Right
Ctrl
[
Indent Code Left
⇧
Tab
Auto Indent Code
Ctrl
/
Line Comment
Ctrl
Alt
/
Block Comment
TutsInsider Actions
Alt
S
Run Code
Ctrl
C
Copy Editor Code
Ctrl
A
Select All Editor Code
Ctrl
S
Save/Download
Ctrl
Alt
X
Rotate
Ctrl
Alt
T
Switch Theme
Ctrl
⇧
C
Open Console
Esc
Close Console