In my html page, i have a table with few rows.If i click on a row, i need to redirect the page to another html page.How to perform this by using jquery.
Note:I need to redirect each row of data to distinct html pages.For example first row data should redirect to user1 profile html page.second row of data should redirect to user2 profile html page.
<table class="table">
<tbody>
<tr>
<td>user 1</td>
<td>10/21/2013</td>
<td class="text-primary">Open</td>
<td>$79.99</td>
<td>Amazing Widget (16 GB, White)</td>
<td>Johnathan</td>
<td class="text-right none"> <a href="#" class="tick_icon gridneed_icon"></a>
<a class="col-md-offset-1 cross_icon gridneed_icon" data-toggle="modal" href="#deleteproduct"></a>
</td>
</tr>
<tr>
<td>user 2</td>
<td>6/21/2013</td>
<td class="text-primary">Open</td>
<td>$79.99</td>
<td>Amazing (16 GB, White)</td>
<td>Doe</td>
<td class="text-right none"> <a href="#" class="tick_icon gridneed_icon"></a>
<a class="col-md-offset-1 cross_icon gridneed_icon" data-toggle="modal" href="#deleteproduct"></a>
</td>
</tr>
</tbody>
</table>
try something like this, use data attribute like below one
HTML CODE
<table class="table">
<tbody>
<tr data-url="some_url1">
<td>39401602</td>
<td>6/21/2013</td>
<td class="text-primary">Open</td>
<td>$79.99</td>
<td>Amazing Widget (16 GB, White)</td>
<td>Johnathan Doe</td>
<td class="text-right none"> <a href="#" class="tick_icon gridneed_icon"></a>
<a class="col-md-offset-1 cross_icon gridneed_icon" data-toggle="modal" href="#deleteproduct"></a>
</td>
</tr>
<tr data-url="some_url2">
<td>39401602</td>
<td>6/21/2013</td>
<td class="text-primary">Open</td>
<td>$79.99</td>
<td>Amazing Widget (16 GB, White)</td>
<td>Johnathan Doe</td>
<td class="text-right none"> <a href="#" class="tick_icon gridneed_icon"></a>
<a class="col-md-offset-1 cross_icon gridneed_icon" data-toggle="modal" href="#deleteproduct"></a>
</td>
</tr>
</tbody>
</table>
JAVASCRIPT CODE
$(function () {
$('table.table tr').click(function () {
window.location.href = $(this).data('url');
});
})
REFERENCE
Data Attribute - http://api.jquery.com/data/
Try using window.location.href
$('table tr').on('click', 'td', function () {
window.location.href = "redirect url";
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With