How to make an anchor tag refer to nothing?


To make an anchor tag refer to nothing, use “javascript: void(0)”. The following link does nothing because the expression "0" has no effect in JavaScript. Here the expression "0" is evaluated, but it is not loaded back into the current document.

Example

Live Demo

<html>
   <head>
      <script>
         <!--
            //-->
      </script>
   </head>
   <body>
      <p>Click the following, This won't react at all...</p>
      <a href="javascript:void(0)">Click me!</a>
   </body>
</html> 

Updated on: 16-Jun-2020

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements