jQueryevent.dataプロパティ_
例
<p>要素ごとにon()メソッドで渡されたデータを返します。
$("p").each(function(i){
$(this).on("click", {x:i}, function(event){
alert("The " + $(this).index() + ". paragraph has data: " + event.data.x);
});
});
定義と使用法
event.dataプロパティには、現在実行中のハンドラーがバインドされたときにイベントメソッドに渡されるオプションのデータが含まれます。
構文
event.data
Parameter | Description |
---|---|
event | Required. The event parameter comes from the event binding function |