这在 jQuery 中可能吗?
$(elem).('.class').html("new data");
我需要更改当前元素上的类的 HTML,因为有多个元素具有此类。我只想更改该特定元素上的类的 HTML。我尝试使用.parent()
最近的孩子,但无济于事。
该函数由位于 tr 内的 td 内的选择标记调用,而我要更改的数据位于下一个 tr 中,因此如下所示:
<tr>
<td>select</td>
<td></td>
<td></td>
</tr>
<tr>the td's which htmls i want to change</tr>
另请注意,<tr>
可以多次添加保持选择,因此将有超过 1 个选择,因此该$(elem)
部分。每当添加包含选择的新 tr 时,也将添加包含 td 的 tr,因此这是一个示例 html 代码:
生成的 HTML 代码:
<tr class="action-row">
<td valign="top">CRM Action: </td>
<td valign="top"><select name="crm_action[]">
<option value="add">Add to Group</option>
<option value="transfer">Transfer to Group</option>
</select>
</td>
<td valign="top">Action: </td>
<td valign="top">
<select name="funnel_type[]" class="funnel-type" onchange="type_switch(this)">
options to determine what to display in this tr onchange
</select>
</td>
<td>
<img src="somewhere/action_delete.png" title="Delete" onclick="delete_row(this)" style="cursor: pointer;"></td>
</tr>
//this part should have been inside the above tr as you can see it the php code above
<tr class="actionrow odd">
<td class="type-label" valign="top"></td>
<td class="type-selection" valign="top"></td>
<td class="type-button" valign="top" align="right" colspan="2"></td>
</tr>
//end
<tr class="action-row">
<td valign="top">CRM Action: </td>
<td valign="top">
<select name="crm_action[]"><option value="add">Add to Group</option>
<option value="transfer">Transfer to Group</option>
</select>
</td>
<td valign="top">Action: </td>
<td valign="top">
<select name="funnel_type[]" class="funnel-type" onchange="type_switch(this)">
another options
</select>
</td>
<td>
<img src="somewhere/action_delete.png" title="Delete" onclick="delete_row(this)" style="cursor: pointer;">
</td>
</tr>
<tr class="actionrow odd">
<td class="type-label" valign="top"></td>
<td class="type-selection" valign="top"></td>
<td class="type-button" valign="top" align="right" colspan="2"></td>
</tr>