Question: I am making a table row clickable but once clicked I want to open a new tab. I tried using `data-target` but that didn't work.

```
<tr class="table-row" data-href="mypage.php" data-target="_blank"></tr>

<script type="text/javascript">
    $(document).ready(function ($) {
        $(".table-row").click(function () {
            window.document.location = $(this).data("href");
        });
    });
</script>

```

Answer: 
could be done like this:

**jQuery: [JSFiddle 1](https://jsfiddle.net/wxc80ybf/2/)**

```js
$('.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](https://jsfiddle.net/wxc80ybf/3/)**

```js
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'));
  });
}

```
Have you tried:

```
<tr class="table-row" 
onclick="window.open('http://website-name.com/mypage.php', '_blank');">

```