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

Introduction to void operator syntax and usage in javascript_javascript skills

WBOY
Release: 2016-05-16 17:40:38
Original
1050 people have browsed it

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
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
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!