The browser has its own default behavior, such as:
Pressing the ENTER key in the form will submit the form, and the right mouse button will pop up the context menu.
To cancel the browser default behavior:
or directly return false:
However, it is important to note that when you use return false:
1, jquery has its own event processing layer, but also the processing package, if the event handler returns false, event bubbling and browser default events will be blocked.
2. Using native JavaScript, returning false in the event handler will only be the most value of the browser default behavior, and event bubbling still exists.
3. Browser default behavior and event bubbling are independent of each other. Blocking event bubbling does not affect the default behavior, and vice versa.
Attention:
Some browser behavior occurs before the event handler executes, meaning that these default behaviors cannot be canceled, such as: The style of the hyperlink on a hyperlink on most browsers changes, which occurs before the focus event and cannot be canceled in the focus event handler.
Browser default behavior