jQueryイベント依頼--複数のイベント
769 ワード
jQueryイベント委任バインディング複数のイベントは、
両方のイベントと要素の順序が異なり、逆または次のいずれかを覚えないでください.
mapパラメータを使用して複数のイベントを追加することもできます
on
またはdelegate
を使用することができる.
- li1
- li2
- li3
$("ul").delegate("li","click mouseover",function(e){
console.log($(e.target).text());
});
両方のイベントと要素の順序が異なり、逆または次のいずれかを覚えないでください.
$("ul").on("click mouseover","li",function(e){
console.log(e.target.innerText);
});
mapパラメータを使用して複数のイベントを追加することもできます
$("ul").on({
click:function(e){
console.log(e.target.innerText);
},
mouseover:function(e){
console.log(e.target.innerText);
}
},"li");