An onclick event in the A tag that determines whether a link to a tag is executed based on the check case in the event

Source: Internet
Author: User

After the OnClick method is added to the a tag, the OnClick method is executed before the action of the property corresponding to the A-tag href is executed, and false is used as the return value if you do not want to perform the href attribute.

<href= "http://www.cnblogs.com/qisel/"  onclick= "method (); return false; " > Click </a>

1. None of the above is performed regardless of the HREF attribute action.

2. The following is the ability to determine whether the link in the href attribute is executed, based on the return true or false , after the JS check.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en"><HTML> <HEAD>  <TITLE>New Document</TITLE>  <METANAME= "Generator"CONTENT= "EditPlus">  <METANAME= "Author"CONTENT="">  <METANAME= "Keywords"CONTENT="">  <METANAME= "Description"CONTENT=""> </HEAD> <BODY>        <ahref= "http://www.cnblogs.com/qisel/"onclick= "Return method ()">Click</a> </BODY> <SCRIPTLANGUAGE= "JavaScript">    functionmethod () {if(1 == 0){            return true; }Else{            return false; }    } </SCRIPT></HTML>

An onclick event in the A tag that determines whether a link to a tag is executed based on the check case in the event

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.