The difference between a label's href= "javascript:void (0)" and href= "#"

Source: Internet
Author: User

Good text to push: A tag of the href= "javascript:void (0)" and href= "#" Difference

Zhang Xin Xu This article is also very interesting, as a slight code neat programmer, the tangled when tangled: is the habit or norms!? Question: Why use href= "javascript:void (0);"?

A tag to write href attribute! ~ with href attribute, natural mouse hand type, as well as can be keyboard focus and focus time to enter analog click behavior (Support carriage return click and default can get focus).

The difference between href= "#" and href= "javascript:void (0)"

# contains a location information, the default anchor is #top that is the top of the page.

and javascript:void (0), only represents a dead link.

When the page is long, it uses # to locate the page in the format:# + ID.

If you want to define a dead link please use Javascript:void (0).

<a href= "javascript:void (0);" > I'm not responding to!</a>
<a href= "#pos" > point I position to the specified position!</a>
<br>
...
<br>
<p id= "POS" > trailing anchor points </p>
The key in Javascript:void (0) is the Void keyword, which is a very important keyword in JavaScript, which specifies that an expression is evaluated but does not return a value.
<body>
<script type= "Text/javascript" >
function GetValue () {
var a,b,c;
A = void (b = 5, c = 7);
document.write (' a = ' + A + ' B = ' + b + ' C = ' + C);
}
</script>
<p> Click the button below to view the results:</p>
<form>
<input type= "button" value= "Point Me" onclick= "getValue ();"/>
</form>

</body>



Click to show results: a = undefined b = 5 c = 7 Article One article two article three

The difference between a label's href= "javascript:void (0)" and href= "#"

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.