Home > Web Front-end > JS Tutorial > body text

What does javascript:void(0) mean?

清浅
Release: 2019-01-28 17:44:09
Original
74498 people have browsed it

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>
Copy after login

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!