我有一個表格單元格,它動態更改爲textarea。當用戶在點擊單元格,它將允許用戶輸入一些文字:獲取動態jQuery表格單元格值
$("#myDataTable tbody tr td:nth-child(4)").click(function(e) {
if ($(this).prev().prev().text() == "") {
var text = $(this).text();
$(this).text('');
$('<textarea />').appendTo($(this)).val(text).select().blur(function() {
var newText = $(this).val();
$(this).parent().text(newText).find('textarea').remove();
});
}
e.stopPropagation();
});
但是,當我點擊了拒絕按鈕來獲取這些值。他們是空的字符串。實際上,當我查看html時,這些tds中沒有任何內容。我如何將這些值放入數組中?
這裏是我的JSFiddle
只需更改相應td的文本內容就不會更改與您的數據表關聯的對象的數據。改變數據。 – tkay