JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<label>
<b>$.parseHTML</b> doesn't work correctly if we are using a string starting with spaces; it should be able to obtain the correct HTML.<br>
In this example I am using a div with HTML event onClick set to: "function(){ONCLICK EVENT}"<br><br>
</label>
</div>
<div><label>RESULTS: </label></div>
<div><label>Using TRIM: </label><label id="yesTrim"></label></div>
<div><label>Not using TRIM: </label><label id="noTrim"></label></div>
<br>
<div>
<label>
Besides <b>$(...HTML STRING with leading spaces...)</b> works correctly <br><br>
</label>
</div>
<div><label>RESULTS: </label></div>
<div><label>Simple parse: </label><label id="simpleParse"></label></div>
JavaScript
$('#noTrim').text(
$( $.parseHTML(' <div onclick="function(){ONCLICK EVENT}" > <label>HELLO WORLD</label></div>') ).attr('onclick')
);
$('#yesTrim').text(
$( $.parseHTML( $.trim(' <div onclick="function(){ONCLICK EVENT}" > <label>HELLO WORLD</label></div>') ) ).attr('onclick')
);
$('#simpleParse').text(
$(' <div onclick="function(){ONCLICK EVENT}" > <label>HELLO WORLD</label></div>').attr('onclick')
);