如何遍历表并在三个不同的数组中收集这些字段的值
How to iterate through table and collect in three different arrays values from that fields?
如何使用JQuery遍历表,并从这些字段中收集三个不同的数组值?我有类似的行
<tr>
<td>
<select id="name_x"></select>
</td>
<td>
<select id="op_x"></select>
</td>
<td>
<input type="text" id="val_x"/>
</td>
</tr>
其中x在每一行中都不同(但都以name_、op_和val_开头)。如何收集?
http://api.jquery.com/attribute-starts-with-selector/
$('tr').each(function(i,el) {
var $this = $(this);
str1 = $this.find('select[id^="name_"]').val();
str2 = $this.find('select[id^="op_"]').val();
str3 = $this.find('input[id^="val_"]').val();
// now do what you like with those strings
});
相关文章:
- 如何在 for 循环中访问 json 数组字段的名称
- 如何通过向用户推送模式引用来更新用户对象's数组字段
- 访问嵌套的 json 数组字段
- PHP 从“选择 - 数组”字段中填充文本框
- 在 Rally SDK 2 中,如何更新数组字段,例如在变更集的工件上
- 遍历 html 模板中的数组字段
- 如何通过按数组字段选择来检索MongoDB文档
- Jquery 添加未传递给 php 的输入数组字段
- 如何在JSON数组字段的基础上从主干集合中提取模型
- 引用到另一个类的数组字段数组字段没有't刷新
- PHP中的HTML数组字段解析
- mongoose.js:我如何从引用的子数组中删除一个属性,同时使用填充和使用其中一个子数组字段作为过滤器
- js serialize()可以处理数组字段名吗?
- 在数组字段上展平嵌套的对象数组
- 如何在mongodb的子文档模式结构中更新数组字段
- 数组字段的弹性搜索日期范围过滤器
- 当数组字段为空时,替换值不能正常工作
- 如何从dc.js / crossfilter / d3中的数组字段中选择元素,并将每个元素用作图表的单独数据点
- 当我从模型中的数组字段中添加或删除对象时,Ember不更新模板
- 从javascript中设置postgres数组字段为null