Home  >  Article  >  Web Front-end  >  Blocking and allowing jquery's bubbling events (three implementation methods)_jquery

Blocking and allowing jquery's bubbling events (three implementation methods)_jquery

WBOY
WBOYOriginal
2016-05-16 17:42:271264browse

Sometimes we don't want bubbling or default events to occur, so we need some jQuery methods to prevent bubbling and default events.
Different levels of blocking can be achieved through the following three methods.

A: return false --->In event handler, prevents default behavior and event bubbling.
return false In event processing, you can prevent default events and bubbling events.

B: event.preventDefault()---> In event handler, prevent default event (allows bubbling).
event.preventDefault() can prevent default events but allow bubbling events to occur during event processing.

C: event.stopPropagation()---> In event handler, prevent bubbling (allows default behavior).
event.stopPropagation() in event processing, can prevent bubbling but allow default behavior the occurrence of events.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn