jQuery 中stop()详解

2019-07-05  本文已影响0人  风与莹的小窝

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title></title>

<style type="text/css">

* {

margin: 0;

padding: 0;

}

div {

width: 100px;

height: 100px;

background-color: red;

}

</style>

</head>

<body>

<button>动画跑起来</button>

<button>stop(true,true)</button>

<button>stop(true,false)</button>

<button>stop(false,true)</button>

<button>stop(false,false)</button>

<div></div>

<script src="js/jquery-2.2.4.min.js"></script>

<script type="text/javascript">

//$("button").css("color","red").css("font-size","24px")

$("button:eq(0)").click(function(){

$("div").animate({

"width": 800

},3000).animate({

"height": 500

},3000)

})

$("button:eq(1)").click(function(){

//清空队列,完成当前动画

$("div").stop(true,true);

})

$("button:eq(2)").click(function(){

//清空队列,不完成当前动画

$("div").stop(true,false);

})

$("button:eq(3)").click(function(){

//不清空队列,完成当前动画

$("div").stop(false,true);

})

$("button:eq(4)").click(function(){

//不清空队列,不完成当前动画

$("div").stop(false,false);//默认

})

</script>

</body>

</html>

上一篇 下一篇

猜你喜欢

热点阅读