Home >Web Front-end >JS Tutorial >What does javascript:void(0) mean?

What does javascript:void(0) mean?

清浅
清浅Original
2019-01-28 17:44:0974658browse

javascript:void in void(0) is an operator in JavaScript. This operator specifies to calculate an expression but does not return a value. void(0) means that it has no effect in JavaScript

We often use code like javascript:void(0) when writing code, so what does this code mean in JavaScript? Woolen cloth? Next, I will introduce it to you in detail in the article.

What does javascript:void(0) mean?

【Recommended course: JavaScript Tutorial

void in Javascript is an operator that specifies to calculate an expression but does not return a value.

Example: No information will appear when the user clicks

<a href="javascript:void(0);" onclick="alert(&#39;ok&#39;);"></a>

This line of code here means that the link does not jump and executes the onClick event. This means that nothing will happen when the user clicks. Because void(0) is calculated as 0, there is no effect on Javascript

Example: A warning message will be displayed after the user clicks the link

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<a href="javascript:void(alert(&#39;warning&#39;))">点击</a>
</body>
</html>

Rendering :

What does javascript:void(0) mean?

Summary: The above is the entire content of this article. I hope that through this article you can understand the meaning of javascript:void(0) .

The above is the detailed content of What does javascript:void(0) mean?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to use confirm methodNext article:How to use confirm method