jQuery

Last-modified: 2013-10-19 (土) 16:43:42

http://api.jquery.com/category/core/

DOM操作

innerHTML

jQuery(selector).html(value);
value = jQuery(selector).html();

テキストコンテント

jQuery(selector).text(textString);
textString = jQuery(selector).text();

子要素をすべて削除

jQuery(selector).empty();

jQueryオブジェクト操作

selectorで複数個の要素が取得された場合の各要素へのアクセス

jQueryObj = jQuery(selector).eq(index);

indexは0~

.get(index)だと、jQueryオブジェクトではなくElementが取得されるらしい。

length = jQuery(selector).length;

forやeachを使う。http://andante.in/j/jquery%E3%81%AB%E3%81%8A%E3%81%91%E3%82%8Beach%E3%81%AE%E5%88%A9%E4%BE%BF%E6%80%A7%E3%81%A8for%E3%81%AE%E6%9C%89%E7%94%A8%E6%80%A7/

HTML要素の表示制御

表示する

jQuery(selector).show();

非表示にする

jQuery(selector).hide();

display:noneと同じ効果。周囲の要素は、空いた領域に詰められる。

現在の表示状態を調べる

jQuery(selector).is(':visible');

フォーム

valueの値

jQuery(selector).val()

ラジオボタン

http://d.hatena.ne.jp/xyk/20110221/1298281217

jQuery UI

http://stacktrace.jp/jquery/ui/