Hard code HTML entity to Javascript code - Javascript DOM

Javascript examples for DOM:Element innerHTML

Description

Hard code HTML entity to Javascript code

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  ww.ja  v  a 2  s.  c om*/
      console.log(aa);
  }

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

Related Tutorials