JSFiddle - React, Tailwind, and code Playground

HTML

Use buttons to load test cases:<br/>
<button onclick="load('<div><div>foo</div></div>')">&lt;div&gt; root</button>
<button onclick="load('<p><div>fooo</div></p>')">&lt;p&gt; root</button>
<br/>
or type directly to the textarea and press <button onclick="parse">parse</button><br/>
<textarea id="html" rows="5" cols="40">
</textarea>
<br/>
Parsed nodes array length: <input id="length" /><br/>
(the whole result is also printed to firebug console)

JavaScript

function parse(){
    var htmlSource = $('#html').val();
    var parsedNodes = $.parseHTML(htmlSource);
    console.debug(parsedNodes);
    $('#length').val(parsedNodes.length);
};

var load = function (htmlSource) {
    $('#html').val(htmlSource);
    parse();    
};

$('#html').on('change', parse);
$( document ).ready(function() {
    $('button')[0].click();
});