Javascriptをはじめ、Ajax、jQueryの著書多数のガイドが、何かと最近騒がれているJa…
北欧好きが、愛用の北欧モノを見せ合うコミュニティ
Javascript関連情報
更新日:2008年12月17日
jQueryのエフェクトメソッドから今回はFadingエフェクトのfadeOutについて紹介します。
<div style="height:100px;
width:100px;
background-color:#ffda10">my1</div>
<button>フェイドアウト</button>
<script type="text/javascript">
jQuery(function($){
$("button","#test1").click(function () {
$("div","#test1").fadeOut();
})
});
</script>
前回同様に、可視化メソッドslideDown()のボタンを追加してみます。それぞれクリックしてみてください。
<div id="test2">
<div style="height:100px;
width:100px;
background-color:#ffda10">my2</div>
<button id="btn1">不可視化</button>
<button id="btn2">slideDown()</button>
</div>
<script type="text/javascript">
jQuery(function($){
$("#btn1","#test2").click(function () {
$("div","#test2").fadeOut();
});
$("#btn2","#test2").click(function () {
$("div","#test2").slideDown();
})
});
</script>
<div id="test3">
<button id="btn3">スイッチ</button>
<div style="display:none;
height:100px;
width:100px;
background-color:#ffda10">my3</div>
</div>
<script type="text/javascript">
jQuery(function($){
var target=$("div","#test3");
$("#btn3").click(function () {
if (target.is(":hidden")) {
target.fadeIn();
} else {
target.fadeOut();
}
})
});
</script>
人気Javascriptランキング
Powered by 価格.com
北欧好きが、愛用の北欧モノを見せ合うコミュニティ