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

Why use _ javascript:void (0)

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "Why to use _ javascript:void (0)". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "Why to use _ javascript:void (0)".

The reason for using "_ javascript:void (0)" is that you can prevent the link from jumping to another page, retain the style of the link, and do not let the link perform the actual operation. The void keyword is used to specify that an expression is evaluated but no value is returned, and "void (0)" means that nothing is done.

The operating environment of this tutorial: windows10 system, javascript1.8.5 version, Dell G3 computer.

What is the reason for using _ javascript:void (0)

Href= "_ javascript:void (0);" this means that the hyperlink executes a js function instead of jumping to an address

Void (0) represents an empty method, that is, does not execute the js function.

Why use href= "_ javascript:void (0);"

_ javascript: is a pseudo protocol, which means that the content of url is executed through javascript. Void (0) means to do nothing, which prevents the link from jumping to another page. This is often done to preserve the style of the link, but not to let the link perform the actual operation

The most critical word in _ javascript:void (0) is the void keyword, and void is a very important keyword in JavaScript, which specifies that an expression is evaluated but does not return a value.

The syntax format is as follows:

Void func () _ javascript:void func ()

Or

Void (func ()) _ javascript:void (func ())

The following code creates a hyperlink that nothing happens when the user clicks.

Example:

123 Click here nothing will happen

Output result:

Thank you for your reading. the above is the content of "Why to use _ javascript:void (0)". After the study of this article, I believe you have a deeper understanding of why you want to use _ javascript:void (0), and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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