Convert string values from variable to HTML in Javascript - Javascript jQuery

Javascript examples for jQuery:String

Description

Convert string values from variable to HTML in Javascript

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <title>ChangeHTML</title> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-3.1.0.slim.js"></script> 
  <script type="text/javascript">
    window.onload=function(){//from  ww w .  j a  va 2s.  c o m
document.getElementById("myName").innerHTML = "<h1>asdf?!</h1>";
    }

      </script> 
 </head> 
 <body> 
  <div id="myName"> 
   <p>Hello~!</p> 
  </div>  
 </body>
</html>

Related Tutorials