JSFiddle - React, Tailwind, and code Playground
by Alex Cougarman
HTML
<div class="testDiv" data-target="http://www.stackoverflow.com" data-open="false"></div>
CSS
.testDiv {
height:100px;
width:200px;
background-color:lightblue;
}
JavaScript
$(document).ready(function(){
var newWindow;
$('.testDiv').on('click', function(e){
var target = $(this).data('target');
var open = $(this).data('open');
console.log(target, open);
if (!open){
$(this).data('open','true');
newWindow = window.open(target);
}
else {
if (newWindow.closed){
newWindow = window.open(target);
}
newWindow.focus();
}
});
})