javascript - 如何在jquery中获取动态表数据中文本框的值
问题描述
我创建了一个带有文本输入框的表格。我想在 tr 元素中获取文本框值的值。我该怎么做?
$(document).on('click', '.overtime_send', function(){
$('#employee_table tr').each(function(row, tr){
var asd = $(tr).find('td:eq(3)').text();//get the value
var asd01 = $(tr).find('td:eq(4)').text();//not get the value of the text box
alert(asd);
});
});
解决方案
使用 the ,.find('input')
因为您的tr
and中只有一个输入.val()
来获取值。
let your_array = [];
$(document).on('click', '.overtime_send', function() {
$('#employee_table tbody tr').each(function(row, tr) {
your_array.push({
emp_id: $(tr).find('td:eq(0)').text(),
input_val: $(tr).find('input').val()
});
});
});
推荐阅读
- azure-data-factory-2 - 数据工厂子项修改或创建日期
- ios - 什么会导致分段选取器控件“弹出”而不是滑动到新选择,仅在实际设备上?
- flutter - 颤振:输入'列表
' 不是 'Widget' 类型的子类型 - ios - 保存 UIDocument 失败并出现权限错误 - `NSCocoaErrorDomain` 代码 `513`
- php - 迁移到新服务器 Laravel 5.8 后页面丢失
- php - PHP XPath 确定是否选中了一个复选框?
- azure - Azure DevOps:服务连接未被识别
- bash - 如何将 awk 结果变量分配给数组,是否可以在循环中的另一个 awk 中使用 awk
- css - 如何让一个图像居中但左上角的另一个图像?
- javascript - 如何测试私有范围或匿名函数?