SOURCE

console 命令行工具 X clear

                    
>
console
$("#start").click(function () {
    var myDiv = $("div");
    myDiv.show("slow");
    myDiv.animate({
        left: "+=200"
    }, 5000);

    myDiv.queue(function () {
        var that = $(this);
        that.addClass("newcolor");
        that.dequeue();
    });

    myDiv.animate({
        left: "-=200"
    }, 1500);
    myDiv.queue(function () {
        var that = $(this);
        that.removeClass("newcolor");
        that.dequeue();
    });
    myDiv.slideUp();
});

$("#stop").click(function () {
    var myDiv = $("div");
    myDiv.clearQueue();
    myDiv.stop();
});
<!doctype html>
<html lang="en">

<head>
	<meta charset="utf-8">
	<title>clearQueue demo</title>
	<style>
	</style>

</head>

<body>

	<button id="start">Start</button>
    <button id="stop">Stop</button>
    <div></div>
</body>
</html>
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
div {
    margin: 3px;
    width: 40px;
    height: 40px;
    position: absolute;
    left: 0px;
    top: 30px;
    background: green;
    display: none;
}

div.newcolor {
    background: blue;
}