Javascript:void (0) Usage explanation

Source: Internet
Author: User
Keywords void (0) Java this
Tags .url address browser expression java javascript link nothing

Javascript:void (0) means nothing! He is not a page URL, but a JavaScript statement void (0), Void is an operator that specifies that an expression is to be evaluated but does not return a value, the expression to be evaluated is "0", so , this is basically a pit dad's writing, completely fooled browser.

If you hover over a link and the target address of the link is displayed on the status bar at the bottom of the browser, the author of the page wants the link to be clicked not to jump directly to a new page, but to perform other actions (such as a preset JS function).

Then why add this? Because the "href" argument in the linked HTML code (link) is not empty, when clicked, the page will automatically jump, if the specified "href" is not legitimate, the page will jump to itself, that is, refresh, if you want to use the link to do something else? Then we're going to " HREF "Specifies a valid parameter that does not refresh the page, so" javascript:void (0) "comes in handy, so we can change the link so that clicking on the link triggers the onclick event, and the page itself does not refresh and the task is reached.

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.