我想选择其祖先为 td 的节点的文本,并将输入标记作为子节点:
输入是:
<tr>
<td width="1"><input type="checkbox" name="marketCodes" value="AE01" onclick="facetCheckboxClicked(this)"></td>
<td style="padding-left:5px;padding-right:5px;">Defense & Security (1028)</td>
<td width="1"><input type="checkbox" name="marketCodes" value="AE02" onclick="facetCheckboxClicked(this)"></td>
<td style="padding-left:5px;padding-right:5px;">Geotechnologies (96)</td>
<td style="padding-left:5px;padding-right:5px;">Aircraft Products & Services (594)</td>
</tr>
预期输出为:
Defense & Security (1028)
Geotechnologies (96)