これはjQueryで可能ですか?
$(elem).('.class').html("new data");
このクラスを持つ要素が複数あるため、現在の要素のクラスの HTML を変更する必要があります。その特定の要素のクラスの HTML のみを変更したい。私は.parent()
最も近い子供たちを使用しようとしましたが、役に立ちませんでした。
関数は、tr 内にある td 内にある select タグによって呼び出され、変更したいデータは次の tr にあるため、次のようになります。
<tr>
<td>select</td>
<td></td>
<td></td>
</tr>
<tr>the td's which htmls i want to change</tr>
また<tr>
、選択を保持すると複数回追加できるため、パーツが複数選択されることに注意してください$(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>