开发者

In JavaScript is it possible on IE to register one event listener to capture all the change, focus, and blur events on the page?

  • In non-IE browsers:
    • The change event bubbles, so you can catch it when it gets to document in the bubbling phase.
    • The focus and blur events don't bubble, but you can catch them on the capture phase with one event listener on document.
  • On IE:
    • None of those 3 events bubb开发者_开发知识库le (including the change event, which is not spec compliant).
    • There is no capture phase on IE.

So, as far as I know, the only way on IE is to register an event listener for change, focus, and blur on every form control. This operation can be expensive when you have a lot of controls. But is there a better way?


jQuery 1.4 defines 'focusin' and 'focusout' to capture focus and blur events for all browsers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜