Jquery-effect-stop
提供:Dev Guides
stop([clearQueue、gotoEnd])メソッド
説明
- stop([clearQueue、gotoEnd])*メソッドは、指定されたすべての要素で現在実行中のすべてのアニメーションを停止します。
構文
このメソッドを使用するための簡単な構文は次のとおりです-
selector.stop( [clearQueue], [gotoEnd] ) ;
パラメーター
これは、この方法で使用されるすべてのパラメータの説明です-
- clearQueue -これはオプションのブール型パラメーターです。 trueに設定すると、アニメーションキューがクリアされ、キューに入っているすべてのアニメーションが効果的に停止します。
- gotoEnd -これはオプションのブール型パラメーターです。 ブール値(true/false)。trueに設定すると、表示および非表示の元のスタイルのリセットやコールバック関数の呼び出しなど、現在再生中のアニメーションがすぐに完了します。
例
以下は、このメソッドの使用方法を示す簡単な例です-
<html>
<head>
<title>The jQuery Example</title>
<script type = "text/javascript"
src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
</script>
<script type = "text/javascript" language = "javascript">
$(document).ready(function() {
$("#go").click(function(){
$(".target").animate({left: '+=100px'}, 2000);
});
$("#stop").click(function(){
$(".target").stop();
});
$("#back").click(function(){
$(".target").animate({left: '-=100px'}, 2000);
});
});
</script>
<style>
p {background-color:#bca; width:250px; border:1px solid green;}
div{position: absolute; left: 50px; top:300px;}
</style>
</head>
<body>
<p>Click on any of the following buttons:</p>
<button id = "go"> GO</button>
<button id = "stop"> STOP </button>
<button id = "back"> BACK </button>
<div class = "target">
<img src = "/jquery/images/jquery.jpg" alt = "jQuery"/>
</div>
</body>
</html>
これにより、次の結果が生成されます–