0
我想重新打开别人问的问题。使用live或delegate模拟mouseenter的最佳方式是什么?原来的问题在这里:mouseenter使用现场或委托?
How should I emulate a mouseenter event using jquery's live functionality?
和OP的建议是:
// 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 2010-12-03 09:51:47