The use of return false in JavaScript

  • 2020-05-16 06:17:43
  • OfStack

In most cases, returning false for the event handler prevents the default event behavior.

For example, click 1 by default < a > Element, the page jumps to the page specified by the href attribute of that element. Return False is equivalent to the terminator, and Return True is equivalent to the executor. In js, return false is generally used to cancel the default action. For example, if you click on a link, in addition to triggering your onclick event (if you specify it), there is also a default event that triggers a jump to the execution page. So if you want to cancel the default action of the object you can return false.

Similarly, return false can be applied to submit the form, for example, we usually in the form, to determine whether the information on the client is true, is filling the information, if one conforms to the above conditions, so we need to, in the client output message, and will not be submitted to the server processing, return flase just can play a prominent role in here - -!


Related articles: