這是可能的jQuery?
$(elem).('.class').html("new data");
我需要更改當前元素的類的HTML,因爲有多個元素具有此類。我只想更改該特定元素上的類的HTML。我嘗試使用.parent()
最接近的孩子,但無濟於事。
功能由一個選擇標記,它是TD是一個tr和我想改變裏面的數據裏面稱爲是下一個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持有運輸署也將增加每當一個新的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>
你想從你選擇到達第二TR上?如果我是對的......每個人都只是回答你的頭銜。 – 2013-04-24 21:43:36
@MohammadAdil是的,但是選擇它自己在另一個tr中,其差異類比具有我想要改變td的tr的差異類 – magicianiam 2013-04-24 21:46:06
你想改變你的選擇變化的文本? – 2013-04-24 21:47:04