jQuery でいくつかのイベント バインディングを試しています。ドキュメントに次の簡単なコードを用意しました。
$(document).ready(function() {
$("p a").each(function(i, selected){
$(selected).hover(
function(event) { alert('over: ' + event.type); },
function(event) { alert('out: ' + event.type); });
}
)
});
そのため、段落内のリンク (セレクターが "p a") の上にマウスを移動すると、アラートが 2 回ポップアップします。したがって、mouseenter と mouseleave は 2 回起動されます。
これは Google Chrome でのみ発生します。Internet Explorer 7、Firefox 3、Opera、およびSafariでは、両方のイベントが 1 回だけ発生します。
なぜこうなった?