bind(events)
version 1.4 以降
解説
マッチした要素に、指定されたオブジェクトのイベントハンドラをバインドします。
複数のイベントハンドラを一度にバインドすることができます。
イベントハンドラのバインドの詳細については、bind(type, [data], fn)を参照してください。
引数
-
events
Object: バインドするイベントハンドラを含むオブジェクト
戻り値
関連
例
例1:click 、mouseover 、mouseout イベントハンドラを含むハッシュを指定し、一度にバインドします。
click イベントでテキストをアラート表示、mouseover イベントでテキストを青色の太字に、mouseout イベントでテキストを元に戻します。
$("#test_1 li").bind({
"click": function(event) {
window.alert($(this).text());
},
"mouseover": function(event) {
$(this).css({"color": "blue", "font-weight": "bold"});
},
"mouseout": function(event) {
$(this).css({"color": "black", "font-weight": "normal"});
}
});
例1
- jQuery
- prototype.js
- Ext
- script.aculo.us
- YUI
|