Computer >> Computer tutorials >  >> Programming >> Javascript

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

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