Adding an onclick event to a text without breaking the line - Javascript DOM Event

Javascript examples for DOM Event:onclick

Description

Adding an onclick event to a text without breaking the line

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <p>
         See our //  w w  w . jav a  2 s  .co m
         <span onclick="openWindow()" style="cursor: pointer; color:blue">test page</span>
          and other sad things...
      </p> 
      <script>
      function openWindow() {
      window.open("https://www.java2s.com");
      }
    
      </script>  
   </body>
</html>

Related Tutorials