我正在使用下面的 jquery 来获取选定的行 ID
<script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
//MainContent_tbl
$(document).ready(function () {
$('#MainContent_tbl tr').click(function (event) {
alert(this.id); //trying to alert id of the clicked row
});
});
</script>
我的问题是我的表(MainContent_tb)不是静态的,我需要将其作为变量传递,任何建议或评论将不胜感激。
最佳答案
$(document).ready(function () {
$('#MainContent_tbl tr').click(function (event) {
var elID = $(this).attr('id');
alert(elID);
});
});
这就是您要找的!
关于jquery - 获取选中的行id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9229735/