jQueryのサンプル基本(メソッド)
メソッドサンプル
toggleサンプル(.toggle)
特定のブロックの表示・非表示を切り替える。
$("#target_toggle").toggle("slow");
このブロックは,<p id="target_toggle"> です.
Ajax(.load)
Ajaxでhello.htmlをロード。
$("#target_load").load("/javascript/sample/hello.html");
ポイント
文字化け対策はUTF-8 with BOMで(参考:BOMとは 【Byte Order Mark】 - 意味・解説 : IT用語辞典)。
html(.html)
alert( $("#sample-pint").html() );
アニメーション
show() / hide()
指定した要素の表示・非表示を切り替え。引数として "slow", "normal", "fast" を付けるとアニメーション。表示中のものを show() したり,非表示のものを hide() することを明示的に回避したい場合は, $() する際に :hidden,:visible 指定する。(#target_effect ブロック)
$("#target_effect").hide();
$("#target_effect").show();
$("#target_effect").hide("fast");
$("#target_effect").show("fast");
$("#target_effect:visible").hide("fast");
$("#target_effect:hidden").show("slow");
slideDown() / slideUp()
スライドさせるアニメーション。引数として "slow", "normal", "fast" でアニメーション速度を指定(#target_effect_slide)
$("#target_effect_slide:visible").slideUp("slow");
$("#target_effect_slide:hidden").slideDown("slow");
fadeIn() / fadeOut()
フェードイン・フェードアウト。引数として "slow", "normal", "fast" でアニメーション速度を指定。(#target_effect_fadeブロック)
$("#target_effect_fade:visible").fadeOut("slow");
$("#target_effect_fade:hidden").fadeIn("slow");
カテゴリ
jQuery
-
jQuery/JSONP/ABROAD01
Others/addrajax
Others/ajaxzip
jQuery/BlockUI
Case Study
Code
jQuery/Corner
mootools/Fancyform
Others/faviconapi
jQuery/Flash
Highslide JS
jQuery/Innerfade
jQuery
jQuery/JSONP
jQuery/Media
mootools
jQuery/NewsSlider
Others
jQuery/Pager
Others/Reflection
jQuery/Superfish
jQuery/TableSorter
Others/table_sortable
jQuery/Tabs
jQuery/ThickBox
YUI/TreeView
YUI