Home >Web Front-end >JS Tutorial >Introduction to void operator syntax and usage in javascript_javascript skills

Introduction to void operator syntax and usage in javascript_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:40:381102browse

void is an operator in JavaScript, the syntax is as follows:
javascript:void(expression)
javascript:void expression
void will calculate the value of the expression, but discard the return value of the expression.
This expression is often used to make a link a dead link:

Copy code The code is as follows:

When this link is clicked, The address jump will not occur, but the onclick function will be executed.
The following method can also achieve the same result
Copy the code The code is as follows:

But "#" contains a location information, the default is Return to the top of the web page, so in order to avoid this situation, you can add a return false statement to the onclick statement
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