Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the meaning of void (0) in javascript

Shulou Source: shulou.com Published: 2022-06-03 08:06:39 09月18日 Update

Today, I will talk to you about what void(0) in javascript means. Many people may not understand it. In order to let everyone know more, Xiaobian summarizes the following contents for everyone. I hope everyone can gain something according to this article.

void in_javascript:void(0) is a very important keyword in JavaScript that specifies that an expression is to be evaluated but does not return a value.

The void operator is used in the following format:

1. _javascript:void (expression)

2. _javascript:void expression

expression is a Javascript standard expression to evaluate. Parentheses are optional, so it is recommended to write.

href="_javascript:void(0);" What does this mean?

The idea is to have the hyperlink execute a js function rather than jump to a link address, and void(0) represents an empty method that does not execute the js function. Links have no effect.

Examples:

Click here click on the link nothing changes

Difference between a href=#and a href=_javascript:void(0)!

Click here to click on the link that will not return to the top of the page

Click here to return to the top of the page

"#" actually contains location information, for example, the default anchor point is #top, which is the top of the page.

And_javascript:void(0) just means a dead link, which is why sometimes pages are long, browsing links are clearly #, but

Jump to the top

_javascript:void(0) is not, so void(0) is better when calling scripts.

Why use href="_javascript:void(0);"?

Javascript: pseudo-protocol, meaning that the content of the url needs to be executed via javascript.

void(0) means do nothing, which prevents links from jumping to other pages. This is often done to preserve the style of the link, but not to allow the link to perform the actual operation,

After clicking on the link, the page does not move, only the link is opened

It works the same, but different browsers vary.

How to use JavaScript?

custom methods

text content

text content

After reading the above, do you have any further understanding of what void(0) means in javascript? If you still want to know more knowledge or related content, please pay attention to the industry information channel, thank you for your support.

Tags: Link content page meaning function operator text method time expression top browse different important top that is location function information key Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB NVidia Huawei Microsoft vpn