如何在覆盖jquery事件处理程序时获取事件

时间:2013-12-19 12:06:39

标签: jquery

我有以下代码:

var oldFocus = $.fn.focus;
$.fn.focus = function () {
    // how to get event here?
    return oldFocus.apply(this, arguments);
};

我怎样才能获得活动对象?

使用jquery 2.0.3

更新

1 个答案:

答案 0 :(得分:1)

$.event.special.focus = {
    trigger: function(e){
        console.log(e);
        return false; // if false, focus is not firing
    }
};

试试这段代码。

按OP编辑:

pushOK的代码是我需要的起点。我需要达到以下评论中详述的目标:

$.event.special.focus = {
    trigger: function(e){
        e.preventDefault();
        return true;
    }
};
相关问题