表中的行(id ='row_property _'+ number)包含四列:
如何遍历每一行并使用jquery从select和input中收集两个数组中的数据?
答案 0 :(得分:1)
好的,在select和input元素中添加类,以便表格如下所示:
<table id="myTable">
<tr>
<td><select class="rowSelect"></select></td>
<td><input type="text" class="rowInput" /></td>
... etc ...
</tr>
</table>
然后你可以在jquery中获取每行中的值:
$(function(){
$('#myTable tr').each(function(){
alert('select value is '+$(this).find('select.rowSelect'));
alert('input value is '+$(this).find('input.rowInput'));
});
});
答案 1 :(得分:0)
var selectArray = $('table tr td > select').map(function() {
return $(this).val();
}).get();
var inputArray = $('table tr td > input:text').map(function() {
return $(this).val();
}).get();
这可能会做你想要的。