Javascript:void (0) meaning

Source: Internet
Author: User

javascript:void (0) meaning

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.

<a href= "javascript:void (0)" > Click here Nothing will happen </a>

In the following example, the user clicks the link and displays a warning message, but does not renege on any value:

<a href= "javascript:void (alert (' Warning!!! '))" > I!</a>.

In the following instance, because void specifies to evaluate an expression but does not return a value, parameter a returns undefined:

function  getValue () {  var  A, B, C;   void (b = 5, c = 7 );  document.write (' a = ' + A + ' B = ' + b + ' c = ' + c);} </script>
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);" > Point I'm not responding.!</a> <a href= "#pos" > point I position to the specified location!</a> <br> <br> <p id= "pos" > Trailing anchor points </p>

Javascript:void (0) meaning

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.