<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style type="text/css">
div{
width: 50px;
height: 50px;
background-color: lightskyblue;
margin: 30px 0 30px 0;
}
</style>
<script src="../js/jquery-3.5.1.js"></script>
<script src="../js/jquery.color.js"></script>
<script>
//停止动画
//$().stop(stopAll,goToEnd)
$(document).ready(function () {
$("#btn_start").click(function () {
$("div").animate({"width":"200px"},2000)
.animate({"background-color":"red"},2000)
.animate({"height":"200px"},2000)
.animate({"background-color":"blue"},2000);
});
//不带参数1,停止当次动画,带参数1,停止全部动画
$("#btn_stop").click(function () {
$("div").stop(true);
});
});
</script>
</head>
<body>
<input type="button" id="btn_start" value="开始">
<input type="button" id="btn_stop" value="停止"><br>
<div></div>
</body>
</html>