$("table tr").click(function () {
var row = $(this);
id = row.find('td').eq(0).text();
$(this).addClass("selected").siblings().removeClass("selected");
});
本文介绍了一种使用jQuery实现的表格行点击事件处理方法,通过该方法,可以为表格的每一行添加点击事件,当点击某一行时,会获取该行的第一列的文本作为ID,并将该行设置为选中状态,同时取消其他行的选中状态。这种处理方式在数据展示和交互设计中非常实用。
$("table tr").click(function () {
var row = $(this);
id = row.find('td').eq(0).text();
$(this).addClass("selected").siblings().removeClass("selected");
});
8992

被折叠的 条评论
为什么被折叠?