insert javascript code in html - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:html

Description

insert javascript code in html

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.5.2.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//w ww . ja  va2 s .  co  m
var href = 'http://java2s.com';
var label = 'test';
var anchor_element = '<a href="' + href + '">' + label + '</a>';
$('#tester').append(anchor_element);
    });

      </script> 
 </head> 
 <body> 
  <div id="tester">
    abcd 
  </div>  
 </body>
</html>

Related Tutorials