Javascriptをはじめ、Ajax、jQueryの著書多数のガイドが、何かと最近騒がれているJa…
北欧好きが、愛用の北欧モノを見せ合うコミュニティ
Javascript関連情報
更新日:2009年02月23日
今回もjQueryのCustomエフェクトのanimateメソッドで、第2引数で利用できる complete、step、queue について試してみます。
<style>
.divs{
height :120px;
width :120px;
padding :4px;
margin-top :2px;
background :#cea8ff;
}
</style>
<div id="test1">
<button id="btn1">GO!</button>
<div id="su1" class="divs"> TEST </div>
</div>
<script type="text/javascript">
jQuery(function($){
$("#btn1")
.click(function () {
$("#su1")
.animate({
opacity : "toggle"
},{ complete : function(){ alert("終了") }
})
})
});
</script>
第2引数で渡したオブジェクトのcompleteメソッドが、アニメーションの動作完了時に実行されているわけです。
<style>
.divs{
height :120px;
width :120px;
padding :4px;
margin-top :2px;
background :#cea8ff;
}
</style>
<div id="test2">
<button id="btn2">GO!</button>
<div id="su2" class="divs"> TEST </div>
</div>
<script type="text/javascript">
function onEndTest(){ alert("終了") }
jQuery(function($){
$("#btn2")
.click(function () {
$("#su2")
.animate({
opacity : "toggle"
},{
complete : onEndTest
})
})
});
</script>
人気Javascriptランキング
Powered by 価格.com
北欧好きが、愛用の北欧モノを見せ合うコミュニティ