Create new element by assigning html string to innerHTML - Javascript DOM

Javascript examples for DOM:Element innerHTML

Description

Create new element by assigning html string to innerHTML

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script language="javascript">
function playIt()/*from   w ww .  j  av  a  2s.c o m*/
{
   document.getElementById("embed").innerHTML="<embed src='play.mp3' autostart=true loop=false volume=100 hidden=true>";
   return true;
}

      </script> 
   </head> 
   <body> 
      <form action="" method="post"> 
         <button type="button" onclick="playIt()">play</button> 
         <div id="embed"></div> 
      </form>  
   </body>
</html>

Related Tutorials