Calling a function by using onClick in a hyperlink - Javascript DOM Event

Javascript examples for DOM Event:onclick

Description

Calling a function by using onClick in a hyperlink

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body>   
      <script type="text/javascript">
            function connect()/*from   w  w  w  .  j ava  2  s.c  o  m*/
            {
            console.log('connected!');
            }
        
      </script>   
      <!-- simulated echo result here --> 
      <a href="#" onclick="connect(); return false;">Testing</a>    
   </body>
</html>

Related Tutorials