API/1.2/Events イベント
Name | Type |
---|---|
ready( fn ) | Returns: jQuery |
DOMの操作や、値の取得が可能になったときに発生するイベント |
Event Handling:イベントハンドラ
Name | Type |
---|---|
bind( type, data, fn ) | Returns: jQuery |
指定したイベント(クリックなど)に呼応したイベント | |
one( type, data, fn ) | Returns: jQuery |
最初の一度だけ発生するイベント | |
trigger( type, data ) | Returns: jQuery |
該当したエレメントで、指定したイベントが発生したとき、呼応するイベント | |
triggerHandler( type, data ) | Returns: jQuery |
This particular method triggers all bound event handlers on an element (for a specific event type) WITHOUT executing the browsers default actions. 動作を見てみるとIE7でtrigger(focus)を押下げると、Focused!が2ヶ並び、focustriggerでは1つで期待通りです。 | |
unbind( type, data ) | Returns: jQuery |
bindしたイベントを削除する |
Name | Type |
---|---|
hover( over, out ) | Returns: jQuery |
htmlの a:hover と同様に、マウスオーバー マウスアウト時にそれぞれの関数を実行するイベント | |
toggle( fn, fn ) | Returns: jQuery |
二つの関数を交互に実行する。 |
Event Helpers:
自分でとりあえず書いてみる。
jQuery("#mouseOver") .mouseover(function(){jQuery("#mouseOver").html("<span>□</span>");}) .mouseout(function(){jQuery("#mouseOver").html("<span>■</span>");});
引数のないイベントの使い方がよくわからなかったので、メモ
<script> $(function(){ $("select").change(function () { var str = ""; $("select option:selected").each(function () { str += $(this).text() + " "; }); $("div").text(str); }) .change(); }); </script> <style> div { color:#555; } </style> </head> <body> <select name="sweets" multiple="multiple"> <option>Chocolate</option> <option selected="selected">Candy</option> <option>Taffy</option> <option selected="selected">Caramel</option> <option>Fudge</option> <option>Cookie</option> </select>.change();の1行がないと、最初にページを表示したときに、selectedの値が表示されない。
Name | Type |
---|---|
Document Object Model Events 邦訳 | |
blur( ) | Returns: jQuery |
フォーカスがなくなったときに発生するイベント | |
blur( fn ) | Returns: jQuery |
フォーカスがなくなったときに関数を実行する | |
change( ) | Returns: jQuery |
値が変更されたときに発生するイベント | |
change( fn ) | Returns: jQuery |
値が変更されたときに関数を実行する | |
click( ) | Returns: jQuery |
マウスクリックイベント | |
click( fn ) | Returns: jQuery |
クリックしたときに関数を実行する | |
dblclick( ) | Returns: jQuery |
ダブルクリックイベント | |
dblclick( fn ) | Returns: jQuery |
ダブルクリックしたときに関数を実行する | |
error( ) | Returns: jQuery |
Triggers the error event of each matched element. | |
error( fn ) | Returns: jQuery |
Binds a function to the error event of each matched element. | |
focus( ) | Returns: jQuery |
blurの反対、フォーカスを得た時に発生するイベント | |
focus( fn ) | Returns: jQuery |
フォーカスを得たときに関数を実行する | |
keydown( ) | Returns: jQuery |
マウスキー押下げている間 | |
keydown( fn ) | Returns: jQuery |
マウスキー押下げている間に関数を実行する | |
keypress( ) | Returns: jQuery |
キーが押された瞬間 | |
keypress( fn ) | Returns: jQuery |
キーが押された瞬間関数を実行する | |
keyup( ) | Returns: jQuery |
押下げたキーを離した瞬間 | |
keyup( fn ) | Returns: jQuery |
押下げたキーを離した瞬間関数を実行 | |
load( fn ) | Returns: jQuery |
| |
mousedown( fn ) | Returns: jQuery |
マウスダウン | |
mousemove( fn ) | Returns: jQuery |
マウスムーブ | |
mouseout( fn ) | Returns: jQuery |
マウスアウト | |
mouseover( fn ) | Returns: jQuery |
マウスオーバ | |
mouseup( fn ) | Returns: jQuery |
マウスアップ | |
resize( fn ) | Returns: jQuery |
リサイズ | |
scroll( fn ) | Returns: jQuery |
スクロール | |
select( ) | Returns: jQuery |
セレクト | |
select( fn ) | Returns: jQuery |
セレクト | |
submit( ) | Returns: jQuery |
サブミット | |
submit( fn ) | Returns: jQuery |
サブミット | |
unload( fn ) | Returns: jQuery |
アンロード ALT+F4等、閉じる作業をが行われたときに発生するイベント |