最終更新:2010-01-04 (月) 11:08:48 (5522d)
Prototype.js
Top / Prototype.js
JavaScriptで使うライブラリ
対応ブラウザ
- The latest version of Prototype is compatible with the following browsers:
- Mozilla Firefox ≥ 1.5
- Microsoft Internet Explorer ≥ 6.0
- Apple Safari ≥ 2.0
- Opera ≥ 9.25
Prototype.js/オブジェクト
拡張されたオブジェクト
追加されたオブジェクト
- Position?
ショートカット
$() //getElementByID $F() //form $A //input $H //url query $R //range $$ //CSSのセレクタ
リファレンス
構文
$()
$()はDOMオブジェクトを表すもので、引数にはid属性の値やDOMオブジェクトを設定する。引数は複数になってもよい。戻り値のDOMオブジェクトはPrototype.jsによる拡張が施されたものになる。
$( 'div1', 'div2', 'div3' ).invoke( 'hide' ); // $( 'div1' ).hide();
$$()
$$('CSSセレクタ')はCSSセレクタに該当するDOMオブジェクト?を取得
//エレメントの指定方法 $$("tag")//タグを指定 $$("#id")//idで指定 $$(".className")//classで指定 $$("input.required")//class=requiredのinput $$("tagName1>tagName2").html("aaa");//子のみ $$("tagName1+tagName2").html("aaa");//tag1の直後のtag2 //? $$("tagName1,tagName2").html("aaa");//カンマ区切りでも指定可能 $$("tagName1 tagName2").html("aaa");//スペース区切りは入れ子構造(子孫全部) //? $$("tagName[attribute]") $$("tagName[attribute=value]") $$("tagName:nth-child(expression)")//式={even,odd,2n,3n+1 etc..} $$("tagName:empty")// $$("tagName:not(条件)")// $$("tagName:first-child")// $$("tagName:last-child")// $$("tagName:enabled")// $$("tagName:disabled")// $$("tagName:checked")// $$("div.about").html("aaa");//tag.class