<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title></title> <script src="jquery-3.5.1.min.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript"> // 入口函数 $(document).ready(function() { var jqDown = $("#down"); var jqUp = $("#up"); var jqStop = $("#stop"); var jqDiv = $("div"); jqDown.click(function() { jqDiv.slideDown(2000); }) jqUp.click(function() { jqDiv.slideUp(2000); }) jqStop.click(function() { // 后续动画不执行,立即执行当前动画 jqDiv.stop(true, false); }) }); </script> <style type="text/css"> div { height: 100px; 100px; background-color: aqua; margin: 10px; } </style> </head> <body> <input type="button" name="" id="down" value="滑入" /> <input type="button" name="" id="up" value="滑出" /> <input type="button" name="" id="stop" value="停止" /> <div id=""> </div> </body> </html>
![image image](https://img2020.cnblogs.com/blog/1747317/202010/1747317-20201011223132605-823380511.png)