javascript void

javascript:void(0) Meaning

We often use code like javascript:void(0), so in JavaScript javascript:void What does (0) mean?

The most critical thing in javascript:void(0) is the void keyword. void is a very important keyword in JavaScript. This operator specifies to calculate an expression but does not return a value.


##The syntax format is as follows:

< ;head>




The following code creates a hyperlink that does nothing when the user clicks on it.

    php中文网(php.cn) 
单此处什么也不会发生

When the user links, void(0) evaluates to 0, but has no effect on Javascript.

In the following example, a warning message is displayed after the user clicks the link:

    php中文网(php.cn)  

点击以下链接查看结果:

点我!

Run the program and try it


In the following example, parameter a will return undefined:

    php中文网(php.cn)  

点击以下按钮查看结果:

Run the program and try it


The difference between href="#" and href="javascript:void(0)"

# Contains With a location information, the default anchor is #top, which is the top of the web page.

And javascript:void(0) only represents a dead link.

When the page is very long, # will be used to locate the specific location of the page. The format is: # + id.

If you want to define a dead link, please use javascript:void(0).

Example

    php中文网(php.cn) 
点我没有反应的!
点我定位到指定位置!
...

尾部定位点

Run the program and try it


Continuing Learning
||
php中文网(php.cn)

点击以下链接查看结果:

点我!
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!