<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery Stop Current Animation and Play Next Animation in Queue</title> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <style> .box{ width: 250px; height: 150px; background: lightgreen; margin-top: 25px; border: 5px solid blue; } </style> <script> $(document).ready(function(){ // Kill and toggle the current sliding animation $(".toggle").on("click", function(){ $(".box").stop().slideToggle(1000); }); }); </script> </head> <body> <p><strong>Note:</strong> Press the "Slide Toggle" button to initiate the animation. To grasp this illustration, click the button again before the animation finishes.</p> <button type="button" class="toggle">Slide Toggle</button> <div class="box"></div> </body> </html>