[英]How do i get a value from a cell in jquery datatables clicking on dropdown inside a row
[英]How do I get the value from <input type=date> inside a cell in jQuery DataTables?
我在DataTable的单元格内有一个动态创建的(当我单击该单元格时) <input type=date>
。
我可以选择日期并且看起来不错,现在我可以迭代遍历表中的所有数据,因为我处理了每一行的数据,效果也很好,问题是当我想从这些输入中获取值时。
我尝试使用data()
和node()
但是未在HTML上显示该值,因为我发现这是应该的方式,所以我无法从HTML中获取它,因此我尝试了以下操作代码,并说它是未定义的。
table.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
// Tried this - return undefined
var node = this.node();
alert(node.cells[0].value);// The typeof(node.cells[0]) is object HTMLTableCellElement
// also this - here shows the HTML without the updated date
var data = this.data();
alert(data);
});
有任何想法吗?
使用下面的代码访问第一列( column: 0
)中单元格内部的input
值。
var table = $('#example').DataTable();
table.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var cell = table.cell({ row: rowIdx, column: 0 }).node();
console.log($('input', cell).val());
});
有关代码和演示,请参见此jsFiddle 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.