In our dailyJavaScriptdevelopment, we will encounter code like javascript:void(0). Many friends are confused when they see this and don’t know what it means. So this What does javascript:void(0) mean in JavaScript? Today we will take you to understand it together!
1. What does Javascript:void(0) mean and its meaning
The most critical thing in javascript:void(0) is the void key Word, void is a very important keyword in JavaScript. This operator specifies to evaluate anexpressionbut does not return a value.
But what does void(0) here mean?
void operator usage format is as follows:
1. javascript:void (expression) 2. javascript:void expression
expression is a Javascript standard expression to be evaluated. The parentheses outside the expression are optional, but are a good practice to write. (Implementation version Navigator 3.0 )
The syntax format is as follows:
1. Usage of Javascript:void(0)
javascript:void(0) means no action is taken. For example:
This means that this link does not jump and executes the onClick event.
I think this code is common among those who have used ajax:
here
Several ways to link
1.window.open(''url'')
2. Usecustom function
徐州 window.location.href=""
Summary:
1 void(0) is used to perform certain processing, but does not refresh the page as a whole In this case, but if you need to refresh the page, you need to be careful.
3 To put it bluntly, href="#" will refresh the page as a whole, while href="javascript:void(0)" Otherwise
Related recommendations:
1.Let’s talk about javascript that is often used in static pages: ; and javascript:void(0)
2.Analysis of the difference between a tag href=# and href=javascript:void(0) in html
3.Use javascript:void(0) with caution, why is it not good to write like this
The above is the detailed content of What does Javascript:void(0) mean and how to use it in JavaScript?. For more information, please follow other related articles on the PHP Chinese website!