[英]In JavaScript is it possible on IE to register one event listener to capture all the change, focus, and blur events on the page?
change
event bubbles, so you can catch it when it gets to document
in the bubbling phase. change
事件起泡,因此您可以在冒泡阶段对其进行document
时捕获它。 focus
and blur
events don't bubble, but you can catch them on the capture phase with one event listener on document
. focus
和blur
事件不会冒泡,但是您可以在捕获阶段使用document
上的一个事件侦听器来捕获它们。 change
event, which is not spec compliant). 这3个事件均不会冒泡(包括不符合规范的change
事件)。 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. 因此,据我所知,IE上的唯一方法是为每个表单控件上的change
, focus
和blur
注册一个事件侦听器。 This operation can be expensive when you have a lot of controls. 当您有很多控件时,此操作可能会很昂贵。 But is there a better way? 但是有更好的方法吗?
jQuery 1.4定义了“ focusin”和“ focusout”来捕获所有浏览器的焦点和模糊事件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.