JSFiddle - React, Tailwind, and code Playground
HTML
<a href="#" class="popup">google</a>
<div id="toNewWindow">Testing
<input type="button" onclick="test()" value="click"/>
</div>
JavaScript
$('.popup').click(function (event) {
event.preventDefault();
var w = window.open("","myWin","height=400px,width=600px");
w.document.write( $("#toNewWindow").html() );
$('#toNewWindow').detach();
} );
var a=3;
function test()
{
alert(a);
}