I’m currently using closest() which navigates up the dom and using this to find the row element tr but it seems to be returning an empty alert dialog indicating that nothing is being retrieved. What am I doing wrong?
JavaScript
$(document).ready(function () {
$('.manage').click(function(){
// find the row we are in
var $self = $( self );
var $row = $self.closest( 'tr' );
// read the id
var $idCell = $row.find( '.id' );
var caseId = $idCell.text();
alert(caseId);
});
});
HTML:
<table border="0" class="sortable">
<tr>
<th>ID</th>
<th>Functions</th>
</tr>
<?php do { ?>
<tr>
<td class="id"><?php echo $row_cases['id'].'-'.$_GET["progress"]; ?></td>
<td><img src="components/manage.png" width="16" height="16" class="manage">
</tr>
<?php } while ($row_cases = mysql_fetch_assoc($cases)); ?>
</table>
Thanks in advance!
You are using
selfinstead ofthis, there is noselfin JavaScript. This should work: