What is javascript:void(0);

Sam Deering

What is javascript:void(0);? This operator allows inserting expressions that produce side effects into places where an expression that evaluates to undefined is desired.

The void operator evaluates the given expression and then returns undefined.

Example Usage

<a href="javascript:void(0);">Click here to do nothing</a>
<a href="javascript:void(document.body.style.backgroundColor='green');">Click here for green background</a>

See this post for further info: Different ways to run a JavaScript function

Further Reading

Free book: Jump Start HTML5 Basics

Grab a free copy of one our latest ebooks! Packed with hints and tips on HTML5's most powerful new features.

No Reader comments

Comments on this post are closed.