$('.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(); – Akki619