Javascript: what does void of 0 mean

  • 2020-03-29 23:49:20
  • OfStack

In Javascript, void is an operator 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 of expression

Expression is a Javascript standard expression to evaluate. The parentheses on the outside of the expression are chosen, but it is a good practice to write them. (implement version Navigator 3.0)

You specify the hyperlink with the void operator. The expression is evaluated but nothing is loaded at the current document.

The following code creates a hyperlink so that nothing happens to the user later. Void (0) evaluates to 0 when the user links, but there is no effect on Javascript:

< A href = "javascript: void (0)" > Nothing can happen here alone. / A>

The following code creates a hyperlink to submit the form when the user orders:

< A href = "javascript: void (document. Form. Submit ())" > Submit the form here alone < / A>

A href=# and a href=javascript:void(0)
# contains a location information
The default anchor is #top which is the top of the page
Javascript :void(0) simply means a dead link
That's why sometimes the page is long and the link is #
It jumps to the top of the page

Javascript :void(0) is not

So it's best to use it when calling scripts
Void (0)
< Input onclick>
< Div onclick> Etc.

Several ways to link

1. The window. The open (" url ")
2. Use custom functions

function openWin(tag,obj) 
obj.href = "Web/Substation/Substation.aspx?stationno="+tag;; 
<a href="javascript:void(0)" onclick="openWin(3,this)"> zhuzhou </a> 


Related articles: