Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

javascript: void(0) meaning


May 06, 2021 JavaScript


Table of contents


javascript: void(0) meaning

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

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

The following code creates a hyperlink that doesn't happen when the user clicks.

"javascript:void(0)" click here and nothing will happen.

Try it out . . .

Void(0) is calculated as 0 when the user links, but has no effect on Javascript.

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

<head>
<script type="text/javascript">
<!--
//-->
</script>
</head>
<body>
<a href="javascript:void(alert('Warning!!!'))" P oint me out!
</body>

Try it out . . .

Parameter a in the following example returns undefined:

<head>
<script type="text/javascript">
<!--
function getValue(){
var a,b,c;
a = void ( b = 5, c = 7 );
document.write('a = ' + a + ' b = ' + b +' c = ' + c );
}
//-->
</script>
</head>

Try it out . . .

The difference between a href and a href, javascript: void (0).

# Contains a location information, the default anchor is the #top the upper end of the page.

Javascript:void(0), on the other, represents only a dead link.

At a very long time, the page # in the format of: .

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

<a href="javascript:void(0); " I didn't react at the point!"
i'm positioning #pos a href" - "I'm positioning to a designated location! .
slt;br>br<br> slt;p id="pos";tail anchors?lt;p>

Try it out . . .

Note: void() simply represents that no value is returned, but the expression in parentheses is still to be run


Related articles

Javascript Encyclodedi: javascript:; Use the introduction with javascript:void(0).