【停止(clearQueue=true)】をクリックすると、待機中のアニメーションがすべてクリアされます。
【停止(clearQueue=false)】ボタンをクリックすると、現在動作中のアニメーションだけが停止されます。
div#sample
div#sample2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="ja" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="imagetoolbar" content="no" /> <title>エフェクト操作:カスタム:stop()の使用例 | jQuery</title> <link rel="stylesheet" type="text/css" href="/content/lib/global.css" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript"> $(function(){ /* 【再生】ボタンをクリックした時に、アニメーション開始 */ $("#btn_animate").click(function(){ $("#sample1").animate({left: '+=100px'}, 2000); $("#sample2").animate({left: '-=100px'}, 2000); }); /* 【停止】ボタンをクリックした時に、アニメーション停止 */ // Stop animation when button is clicked $("#btn_stop_all").click(function(){ $(".sample").stop(true); }); $("#btn_stop").click(function(){ $(".sample").stop(false); }); /* 【逆再生】ボタンをクリックした時に、逆方向にアニメーションする */ $("#btn_back").click(function(){ $("#sample1").animate({left: '-=100px'}, 2000); $("#sample2").animate({left: '+=100px'}, 2000); }); }); </script> <style type="text/css"> #wrap { text-align:center; } .sample { margin:10px auto; width:100px; height:100px; background:red; position:relative; line-height:100px; text-align:center; } </style> <link rel="stylesheet" type="text/css" href="/common/css/example.css"></head> <body id='example3' class='example'><div class="ads" style="margin:32px auto;text-align:center;"></div><h1 class='h'><a href='/'>PHP & JavaScript Room</a> :: 設置サンプル</h1> <h3 class='h'>実行結果</h3> <div id="wrap"> <h1>エフェクト操作:カスタム:stop()の使用例 | jQuery</h1> <p>【停止(clearQueue=true)】をクリックすると、待機中のアニメーションがすべてクリアされます。<br>【停止(clearQueue=false)】ボタンをクリックすると、現在動作中のアニメーションだけが停止されます。</p> <!-- CODE --> <p> <button id="btn_animate">再生</button> <button id="btn_stop_all">停止(clearQueue=true)</button> <button id="btn_stop">停止(clearQueue=false)</button> <button id="btn_back">逆再生</button> </p> <p id="sample1" class="sample">div#sample</p> <p id="sample2" class="sample">div#sample2</p> <!-- / CODE --> </div> </body> </html>