Returnfalse in JavaScript _ javascript skills

Source: Internet
Author: User
This article mainly introduces the use of returnfalse in JavaScript. In most cases, false is returned for the event handler function, which can prevent default event behavior, for more information about how to avoid default event behavior, see if false is returned for the event handler function in most cases.

For example, if you click an element by default, the page will jump to the page specified by the href attribute of the element. Return False is equivalent to the Terminator, and Return True is equivalent to the executable. In js, return false is generally used to cancel the default action. For example, when you click a link, in addition to triggering your onclick event (if you specify it), you also need to trigger a default event to execute the page Jump. So if you want to cancel the default action of an object, you can return false.

Similarly, return false can be applied to form submission. For example, when verifying a form, we usually need to check whether the information is true or not, and whether the information is missing, if the above conditions are met, we need to output the prompt information on the client, instead of submitting it to the server for processing. return flase can be used here --!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.