Get a selected div portion from a variable containing html code by using javascript - Javascript jQuery

Javascript examples for jQuery:Selector

Description

Get a selected div portion from a variable containing html code by using javascript

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.7.1.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//from ww  w.  ja v a  2s . co m
var myhtml = "here is my data outside div <div id='message'>inside div with id message</div>";
$('body').append(myhtml);
console.log($('div#message').text());
    });

      </script> 
 </head> 
 <body>  
 </body>
</html>

Related Tutorials