0
他の人が尋ねた質問をもう一度開きたいです。ライブまたはデリゲートでマウスをエミュレートする最良の方法は何ですか?liveenterまたはdelegateを使用しているマウスセンターですか?
How should I emulate a mouseenter event using jquery's live functionality?
そしてOPの提案だった:元の質問はここにあった
$("#id").delegate(".selector", "mouseover", function(){
if(!$(this).hasClass("bound")){
$(this).hover(function(){
alert('entering');
},
function(){
alert('leaving');
}).mouseover().addClass("bound");
}
});
を誰もがよりよい解決策を持っています:
// mouseenter emulation
jQuery('.selector').live('mouseover',function (e) {
// live sees all mouseover events within the selector
// only concerned about events where the selector is the target
if (this != e.target) return;
// examine relatedTarget's parents to see if target is a parent.
// if target is a parent, we're "leaving" not entering
var entering = true;
jQuery(e.relatedTarget).parents().each(function() {
if (this == e.target) {
entering = false;
return false; // found; stop searching
}
});
if (!entering) return;
/*
the rest of my code
*/
});
「質問」はわかりません。 – jAndy