Home  >  Article  >  Web Front-end  >  How to use return false in JavaScript

How to use return false in JavaScript

怪我咯
怪我咯Original
2017-07-16 10:47:591628browse

This article mainly introduces the usage of return false in JavaScript. In most cases, it is the event processingfunction Returning false can prevent the default event behavior . Friends who need it can refer to

In most cases, returning false for the event processing function can prevent the default event behavior.

For example, by default, clicking an 3499910bf9dac5ae3c52d5ede7383485 element 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 executor. The function of return false in js 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 trigger a default event, which is to execute a page jump. So if you want to cancel the default action of the object, you can return false.

Similarly, return false can be applied to form submission. For example, when we usually verify the form, we need to judge whether the information is true and whether the information is missing. If any of the above conditions are met, , then we need to output the prompt information on the client without submitting it to the server for processing. Return flase can show its talents here - -!

For example

if(a!=b){
    return fasel;

}else{
    alert(11);

}

The above is the detailed content of How to use return false in JavaScript. For more information, please follow other related articles on the PHP Chinese website!

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