Changing div content using jQuery - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:html

Description

Changing div content using jQuery

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-2.1.0.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/*from  w ww  . j a  va2  s.c  om*/
server = "Testing123",
content = "",
background = "";
content = '<p class="server-message ' + server + '">testing <strong>' + server + '</strong> server</p>';
$("#spock").html(content);
    });

      </script> 
 </head> 
 <body> 
  <div id="spock"></div>  
 </body>
</html>

Related Tutorials