Passing string with space character as parameter to onclick function - Javascript DOM Event

Javascript examples for DOM Event:onclick

Description

Passing string with space character as parameter to onclick function

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <div id="div"></div> 
      <script>
  var aa = 'TAGS(\\"a&nbsp;b\\")';
  var div = document.getElementById('div');
  div.innerHTML = '<a href="#" onClick=passSearchTerm("' + aa + '");>View</a>';
  function passSearchTerm(aa) {/*from w w  w  .  j  a va2s. c  o m*/
      console.log(aa);
  }

      </script>  
   </body>
</html>

Related Tutorials