Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the meaning of void (0) in javascript

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report