1
当得到我有以下代码:如何在事件重写jQuery的事件处理程序
var oldFocus = $.fn.focus;
$.fn.focus = function() {
// how to get event here?
return oldFocus.apply(this, arguments);
};
我怎样才能在活动对象?
更新:使用jQuery 2.0.3
当得到我有以下代码:如何在事件重写jQuery的事件处理程序
var oldFocus = $.fn.focus;
$.fn.focus = function() {
// how to get event here?
return oldFocus.apply(this, arguments);
};
我怎样才能在活动对象?
更新:使用jQuery 2.0.3
$.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;
}
};
我知道我可以做到这一点,谢谢。但那不是我想要的。我需要覆盖默认的焦点动作。 –
@AndrewBullock你正在为之而行的行为是什么? –
我有很多调用.focus()的代码。我想在移动设备上防止此元素聚焦,但我希望任何onfocus处理程序触发。 –