jQuery — Stop
stop()
$("div").stop(); // Stop current animation
stop(true)
$("div").stop(true); // Stop and clear queue
stop(true, true)
$("div").stop(true, true); // Stop, clear queue, jump to end
Practical: Hover Animations
$(".hover-box").hover(
function() {
$(this).stop().animate({ width: "200px" }, 300);
},
function() {
$(this).stop().animate({ width: "100px" }, 300);
}
);
finish()
$("div").finish(); // Stop and jump to end of ALL queued animations
Animation Queue Behavior
Without stop(), animations queue up:
// BAD: Multiple clicks cause stacking
$("div").click(function() {
$(this).animate({ left: "+=100px" }, 500);
});
// GOOD: stop() clears the queue
$("div").click(function() {
$(this).stop().animate({ left: "+=100px" }, 500);
});
stop() Parameters
| Parameter | Default | Description |
|---|---|---|
| clearQueue | false | Clear remaining animations |
| jumpToEnd | false | Jump to current animation end |
Mini Practice
- Stop a hover animation on mouse leave
- Use stop(true) to clear the queue
- Use finish() to jump to end
- Test animation stacking without stop()
Up Next
Continue with Callback — executing code after animations complete.
Related Topics
Frequently Asked Questions about Stop
What is Stop in jQuery?
Stop is a fundamental concept in jQuery. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn Stop?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Stop.
Why is Stop important in jQuery?
Stop is essential for jQuery development. Understanding this concept will help you write better code and solve real-world problems more effectively.