我目前正在使用最接近 ()向上导航 dom 并使用它来查找行元素tr但它似乎返回一个空警报对话框,指示没有检索任何内容。我究竟做错了什么?
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>
提前致谢!