Home >Web Front-end >JS Tutorial >What does javascript:void(0) mean?
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.
【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('ok');"></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('warning'))">点击</a> </body> </html>
Rendering :
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!