HTML block stored as var javascript - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:html

Description

HTML block stored as var javascript

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <script id="htmlTemplate" type="text/x-tmpl">
    This <h1>is</h1> templated.

      </script> 
  <script src="https://code.jquery.com/jquery-latest.min.js"></script> 
  <script type="text/javascript">
    $(document).ready(//w  w w  .j  a va 2  s.c o  m
        function() {
            $('#2nd').html($('#htmlTemplate').text());
        }
    );

      </script> 
 </head> 
 <body> 
  <div id="1st">
    First div 
  </div> 
  <div id="2nd">
    Second div 
  </div>  
 </body>
</html>

Related Tutorials