您可以在父节点 f.ex (jQuery) 上重新触发相同的事件对象。您需要先复制事件对象并将其传递到触发器中,以便在气泡中捕获相同的事件属性(f.ex e.pageX):
var copy = $.extend(true, {}, e);
setTimeout(function() {
$(copy.target.parentNode).trigger(copy);
},500);
e.stopPropagation();
演示:http://jsfiddle.net/GKkth/
编辑
根据您的评论,我认为您正在寻找类似的东西:
$.fn.bindFirst = function(type, handler) {
return this.each(function() {
var elm = this;
var evs = $._data(this).events;
if ( type in evs ) {
var handlers = evs[type].map(function(ev) {
return ev.handler;
});
$(elm).unbind(type).on(type, function(e) {
handler.call(elm, e, function() {
handlers.forEach(function(fn) {
fn.call(elm);
});
});
});
}
});
};
此原型允许您绑定一个“高级处理程序”,该处理程序包含一个next 函数,该函数将在您需要时将所有先前的处理程序执行到同一元素。 像这样使用它:
$('button').click(function() {
console.log('first');
}).click(function() {
console.log('second');
}).bindFirst('click', function(e, next) {
console.log('do something first');
setTimeout(next, 1000); // holds the other handlers for 1sec
});
演示:http://jsfiddle.net/BGuU3/1/