Jquery — Action fires on any event [duplicate]

↘锁芯ラ 提交于 2019-12-01 14:39:11

问题


Is there something in jquery where a function is triggered when any event is fired?

I'd like something like this:

$("*").anyEvent(function(){
  $("#error").html("");
});

回答1:


$('*').on('blur change click dblclick error focus focusin focusout hover keydown keypress keyup load mousedown mouseenter mouseleave mousemove mouseout mouseover mouseup resize scroll select submit', function(){
  $('#error').empty();
});

...but would you want to do this?



来源:https://stackoverflow.com/questions/5123356/jquery-action-fires-on-any-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!