好日子所有,选择值 - jQuery的
我有行和值的表像下面
<tr id="value_12">
<td>firstanme_1</td>
<td>lastname_1</td>
</tr>
<tr id="value_14">
<td>firstanme_2</td>
<td>lastname_2</td>
</tr>
,我使用jQuery是(这是错误的)。
$('#table_id tr').each(function() {
serializedData += '&' + $(this).attr('id') + '=' + $(this).attr('id')+'_'+$(:first_child).text();
});
我期待与TR一起只提取每个TR的第一个名字即属性的serialisedData字符串作为最后一部分(最后一个值,分隔符“_”后)。
我可能是像$(this).firstchild()。text()..但它似乎不工作。 有人可以请帮助以正确的方式得到第一个孩子在这种情况下。
你'[0]'是不正确 - 它提取原始DOM元素。也没有称为'tr'的变量。 – Alnitak 2013-03-10 10:27:43