Change link text in HTML using JavaScript - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Anchor

Description

Change link text in HTML using JavaScript

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script type="text/javascript">
      function open_fun() {/*from   ww w  . j  a  v a 2  s . c  o m*/
        document.getElementById('link').innerHTML = "<a href='javascript:clo_fun()'>CLOSE</a>";
      }
      function clo_fun() {
        document.getElementById('link').innerHTML = "<a href='javascript:open_fun()'>OPEN</a>";
      }
    
      </script> 
   </head> 
   <body> 
      <div id="link">
         <a href="javascript:open_fun()">OPEN</a>
      </div>  
   </body>
</html>

Related Tutorials