【发布时间】:2015-10-02 17:12:59
【问题描述】:
我在 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);
});
有什么想法吗?
【问题讨论】:
-
有值的不是TD,是输入,使用
node.cells[0] .children[0] .value
标签: javascript jquery html dom datatables