JSFiddle - React, Tailwind, and code Playground
HTML
<iframe id="myIframe"></iframe>
JavaScript
var doc = document.getElementById('myIframe').contentWindow.document;
var $html = $('*', doc);
$html.html('\
<!DOCTYPE html>\
<html lang="en">\
<head>\
<style>\
function test() {\
return true;\
}\
</style>\
</head>\
<body>\
<h1>Test</h1>\
</body>\
</html>');
$('#myIframe').contents().find('body').find('h1').text('modified!');
console.log($('#myIframe').contents().find('*').html());