我已经在表格和表格内动态添加了行,我已经填满了下拉列表,但我无法获得下拉列表的选定值。我试图遍历表格单元格,但它给出了下拉列表中的所有值。
请提前表示感谢。
下面是我写的示例代码。
函数GetTableValues() { var services = new Array();var .find=$()tbody(‘tbody’);//获取总行数var len = table.rows.length;//循环遍历表行。对于(var i= 1;i
发布于 2021-11-29 05:38:09
这是一个关于如何从表中获取选定值的想法。假设你得到一个表,每一行都有一列下拉列表。所有这些下拉列表都是带值选择的。
var arr= [];
//find all <td> elements in tbody and loop them
$('#tableID').find('tbody').find('td').each(function(){
//target to the dropdown list elements and get the selected value
var selectedValue = $('option:selected',$(this).find('select')).text();
//attach to array
arr.push(selectedValue);
});https://stackoverflow.com/questions/70150056
复制相似问题