Native Methods to Convert the String to a Set of DOM Nodes

  1. <div id="div1"></div>  
  2. <button id="btn">click</button>  
  3.    
  4.    
  5. $(function(){  
  6.    $('#btn').on('click', function(){  
  7.       // Add some HTML  
  8.       parsedHtml = $.parseHTML( "Sentence has <strong>strongly typed text</strong> in it.<br />" );  
  9.       $('#div1').append(parsedHtml);  
  10.       // Append parsed HTML node names  
  11.       $.each( parsedHtml, function( i, el ) {  
  12.          $('#div1').append( el.nodeName + "<br />" );  
  13.       });  
  14.    });  
  15. });