• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » JScript » What Does JavaScript:void(0) Mean?
Next →
← Prev

What Does JavaScript:void(0) Mean?

By Dinesh Thakur

The word void means “empty space,” as per the dictionary. “Nothing” in programming is returned when there is no result to return.

We’ll be covering the following topics in this tutorial:

  • What does “javascript:void(0)” mean?
  • What is the use of void 0?

What does “javascript:void(0)” mean?

The undefined value is returned when evaluating an expression with the void operator. Generally, this operator indicates an undefined value, almost always using ” void(0)”. (which is equivalent to “void 0”). The acronym is frequently used with hyperlinks. Typically, the browser loads a new web page when it loads a new webpage. Using Javascript’s void(0), you can show a page won’t refresh or load when a link is clicked.

We can use the operand 0 in two ways that are void(0) or void 0. Both of these methods are the same. The JavaScript function:void(0) tells the browser not to do anything, i.e., to restart the browser. It makes it easier for readers to find certain parts of the webpage without having to reload. So, using void(0) on such links prevents the reloading of the page but allows to perform a useful function such as updating a value on the webpage.

It is also used to prevent unwanted redirecting of the page.

An explanation is provided here: void operator.

It will help if you use the href attribute on links because a javascript: URL will force a browser to display the plaintext version of the result of evaluating that script. If the search returns no results, then the browser goes on to the same URL. “Void” is a small and simple script that resolves to undefine.

What is the use of void 0?

The HTML author is improperly using the unclickable anchor element in place of the functional button element. Developers often abuse anchor tags to create pseudo-buttons by setting hrefs to “#” or “javascript:void(0)” to prevent the page from refreshing.

Example

<!DOCTYPE html>
<html>
 <head>
   <title>javascript:void(0)" Example</title>
 </head>
 <body>
   <a href="javascript:void(0);" ondblclick="alert('Double Click Me')">Double Click Me</a>
 </body>
</html>

You’ll also like:

  1. Void Functions in C
  2. void Pointers in C
  3. Write C++ Illustrates the use of void pointers.
  4. JavaScript Operators | Types of JavaScript Operators
  5. Write A C++ Program To A Simple Program That Demonstrates Void ().
Next →
← Prev
Like/Subscribe us for latest updates     

About Dinesh Thakur
Dinesh ThakurDinesh Thakur holds an B.C.A, MCDBA, MCSD certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps.

Dinesh Thakur is a Freelance Writer who helps different clients from all over the globe. Dinesh has written over 500+ blogs, 30+ eBooks, and 10000+ Posts for all types of clients.


For any type of query or something that you think is missing, please feel free to Contact us.


Primary Sidebar

JavaScript Tutorials

JavaScript Tutorials

  • JavaScript - Home
  • JavaScript - Operators
  • JavaScript - Comments
  • JavaScript - If...Else
  • JavaScript - For Loop
  • JavaScript - Popup Boxes
  • JavaScript - Switch Statement
  • JavaScript - while Loop
  • JavaScript - Functions
  • JavaScript - Variables
  • JavaScript - Statements
  • JavaScript - Substring()
  • JavaScript - indexOf()
  • JavaScript - Match()
  • JavaScript - Replace()
  • JavaScript - Search()
  • JavaScript - Split()
  • JavaScript - Substr()
  • JavaScript - Blink()
  • JavaScript - Anchor()
  • JavaScript - Big()
  • JavaScript - Strings Object
  • JavaScript - String Format
  • JavaScript - Length Property
  • JavaScript - Prototype
  • JavaScript - Slice Substr Vs Substring
  • JavaScript - JavaScript:void(0)

Other Links

  • JavaScript - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2023. All Rights Reserved.