JSFiddle - React, Tailwind, and code Playground
HTML
<button class="preview">click to preview</button>
<button class="download">CLick to Download</button>
JavaScript
$(document).ready(function(){
var rohit = "<h2>Hello i m Dynamic Heading </h2>";
$('.preview').on('click', function(){
var myWindow = window.open('', "rohit", "width=800, height=400", '_blank');
myWindow.document.write(rohit);
});
$('.download').on('click', function(){
alert(rohit);
// here download code with html format how to do this .
});
});