[英]Having Issue on Getting Row Data Into an Array From jQuery DataTable
您能否看一下这个演示 ,让我知道为什么我无法将选定的行放入数组中? 他用来获取数据的代码:
$(document).ready(function () {
var arrLoadDb = [];
$('#example').DataTable();
$('.add-row-db').on('click', function (e) {
var $this = $(this);
$this.closest('tr').find('td:not(td:first, td:last)').each(function () {
arrLoadDb.push($(this).text());
console.log(arrLoadDb);
});
});
});
但我得到这个结果而不是数组!
看看这个http://jsfiddle.net/Ratan_Paul/6egzjjtf/3/
$(document).ready(function() {
var arrLoadDb = [];
$('#example').DataTable();
$('.add-row-db').on('click', function(e){
var $this = $(this);
arrLoadDb = []
$this.closest('tr').find('td:not(td:first, td:last)').each(function(){
arrLoadDb.push($(this).text());
});
console.log(arrLoadDb);
});
} );
每次单击按钮时,它将搜索除第一列和最后一列以外的所有列值。
对于每个按钮,我们需要清除数组
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.