15.2.5 Event Cancellation

贡献者:deepfish 类别:英文 时间:2022-08-31 00:14:03 收藏数:9 评分:0
返回上页 举报此文章
请选择举报理由:




收藏到我的文章 改错字
Browsers respond to many user events, even if your code does not: when the user clicks the
mouse on a hyperlink, the browser follows the link. If an HTML text input element has the
keyboard focus and the user types a key, the browser will enter the user's input. If the
user moves their finger across a touch-screen device, the browser scrolls. If you
register an event handler for events like these, you can prevent the browser from
performing its default action by invoking the preventDefault() method of the event
object. (Unless you registered the handler with the passive option, which makes
preventDefault() ineffective.)
Canceling the default action associated with an event is only one kind of event
cancellation. We can also cancel the propagation of events by calling the
stopPropagation() method of the event object. If there are other handlers defined on the
same object, the rest of those handlers will still be invoked, but no event handlers on
any other object will be invoked after stopPropagation() is called. stopPropagation()
works during the capturing phase, at the event target itself, and during the bubbling
phase. stopImmediatePropagation() works like stopPropagation(), but it also prevents the
invocation of any subsequent event handlers registered on the same object.
声明:以上文章均为用户自行添加,仅供打字交流使用,不代表本站观点,本站不承担任何法律责任,特此声明!如果有侵犯到您的权利,请及时联系我们删除。
文章热度:
文章难度:
文章质量:
说明:系统根据文章的热度、难度、质量自动认证,已认证的文章将参与打字排名!

本文打字排名TOP20

登录后可见