JSFiddle - React, Tailwind, and code Playground
HTML
<h2>Evaluation count</h2>
<em>(all should equal 2)</em>
<ul style="margin-top:0;">
<li>no <code>type</code>: <b name="">0</b></li>
<li>text/javascript: <b name="text/javascript">0</b></li>
<li>text/ecmascript: <b name="text/ecmascript">0</b></li>
</ul>
<h2>HTML</h2>
<em>(should not contain <code>script</code>s)</em>
<textarea id="html" rows="12"></textarea>
CSS
* { margin-bottom: 0 }
textarea { width: 100%; }
JavaScript
var html = $.map([ "", "text/javascript", "text/ecmascript" ],
function( type ) {
return ('<scr'+'ipt type="%">' +
'$("[name=\'%\']").text(function( i, text ){ return +text + 1; });' +
'</scr'+'ipt>
').replace(/%/g, type);
}).join("");
$("#html").val(
$("<div/>")
.append( html )
.append( "<div>" + html + "</div>" )
.html().replace( /\n{3,}/g, "\n\n" )
);