【发布时间】:2015-11-25 06:51:20
【问题描述】:
$('.example tbody').on('click', 'tr', function (){
var id = this.id;
var index = $.inArray(id, selected);
if (index === -1)
{
selected.push(id);
} else
{
selected.splice(index, 1);
}
$(this).toggleClass('selected');
});
$('#btn').click(function (){
var dataArr = [];
var rowCount = table.rows('.selected').data().length;
alert(rowCount);
});
这里是选择多行的代码。单击按钮时,我需要获取所选行的第一列值并存储在数组 dataArr[] 中。请帮我解决这个问题。
【问题讨论】:
-
通常,选项之一 $("#"+this.id td:first-child).html();