我在我的MVC应用程序中有一个表.我想获取所选行的id.我使用jQuery捕获了tr的click事件.表格样本如下所示
<table id="resultTable">
<tr id="first">
<td>c1</td>
<td>c2</td>
</tr>
<tr id="second">
<td>c3</td>
<td>c4</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
我正在使用以下脚本来访问行单击事件
$(document).ready(function () {
$('#resultTable tr').click(function (event) {
alert(this.); //trying to alert id of the clicked row
});
});
Run Code Online (Sandbox Code Playgroud)
但它没有工作.如何获得选择的行ID.??任何想法?
ste*_*ecb 19
$(document).ready(function () {
$('#resultTable tr').click(function (event) {
alert($(this).attr('id')); //trying to alert id of the clicked row
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
61157 次 |
| 最近记录: |