How to open new tab using data-href
could be done like this:
jQuery: JSFiddle 1
$('.table-row').each(function() {
var $th = $(this);
$th.on('click', function() {
window.open($th.attr('data-href'), $th.attr('data-target'));
});
});
Pure JS: JSFiddle 2
var tableRows = document.getElementsByClassName('table-row');
for (var i = 0, ln = tableRows.length; i < ln; i++) {
tableRows[i].addEventListener('click', function() {
window.open(this.getAttribute('data-href'), this.getAttribute('data-target'));
});
}
This should work. It will open new tab;
HTML
<table>
<tr class="table-row" data-href="mypage.php" data-target="_blank">
<td>something</td>
</tr>
</table>
JavaScript
$(document).ready(function ($) {
$(".table-row").click(function () {
window.open($(this).data("href"), $(this).data("target")); // Open new tab line
});
});