JSFiddle - React, Tailwind, and code Playground
by ocanal
HTML
<div data-item="true" data-href="http://google.com">
item-1
</div>
<div>
item-1
</div>
<div>
item-1
</div>
CSS
div {
width: 50px;
height: 50px;
background-color: red;
border: 1px solid #fff;
display: inline-block;
}
JavaScript
$('body').on('click', '[data-item]', function(e) {
var targetUrl = $(this).attr('href') || $(this).data('href');
alert(targetUrl);
var currentUrl = window.location.href;
window.location = targetUrl;
window.open(currentUrl, '_blank');
e.preventDefault();
return false;
});