I'm trying to trigger a button (inside one of my table) when the user clicks on a <tr>
tag object, as below:
$(document).ready(function(){
$('body').on('click', 'tr', function(){
var tridx = $(this).data('track-id');
$('td div#play'+tridx).click();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table class="sortable">
<thead>
<tr>
<th data-sort="nope">id</th>
<th data-sort="name">Artist</th>
<th data-sort="name">Title</th>
<th data-sort="name">Genre</th>
<th data-sort="duration">Duration</th>
<th data-sort="date">Release</th>
</tr>
</thead>
<tbody>
<tr data-track-id="252">
<td>
<div data-track-name="1" data-track-id="252" id="play252" class="playbtn252" style="display: none;"></div>
<div id="countlist252" data-count-list="1" style="display: block;">1</div>
</td>
<td>Simon Deoro</td>
<td>1</td>
<td>1</td>
<td>3:47</td>
<td>2016-12-06</td>
</tr>
<!-- more tr -->
</tbody>
</table>
The tridx
is correct, however I get this error from console:
Uncaught RangeError: Maximum call stack size exceeded
What's wrong in my code, I cannot understand it seems everything correct to me?