Extract DOM Node from HTML String - Javascript jQuery

Javascript examples for jQuery:String

Description

Extract DOM Node from HTML String

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.8.3.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/*from w ww. j a va  2  s .c om*/
var html = "<html><body><p>Hello, World!</p><p>Ciao!</p></body></html>";
var str=$('<div>').append($(html)).html()
$('textarea').val( str)
    });

      </script> 
 </head> 
 <body> 
  <textarea cols="60" rows="10"></textarea>  
 </body>
</html>

Related Tutorials