私はjqueryを使用しており、「エラー」クラスを持つ前のdivを見つけたい
私のhtmlコード:
<table class="questions">
<tr>
<td class="heading">1
<div class="error"></div>
</td>
<td colspan="4">
<textarea class="textcontrol required" name='questionT136'>
</textarea>
</td>
</tr>
<tr>
<td></td>
<th><label for="reponse137-3">Très satisfaisant</label></th>
<th><label for="reponse137-4">Satisfaisant</label></th>
<th><label for="reponse137-5">Insatisfaisant</label></th>
</tr>
<tr class="q">
<td class="heading">
2
<div class="error"></div>
</td>
<td class="questionradio"><input class="required" id='reponse137-3'
name='questionN137' type='radio' value='3'></td>
<td class="questionradio"><input class="required" id='reponse137-4'
name='questionN137' type='radio' value='4'></td>
</tr>
</table>
たとえば、reponse137-3から、以前の class="error" の値を変更したいと思います。私はすでにそのオブジェクトにアクセスしようとしました:
$('#reponse137-3').prev(".error")
しかし、うまくいきません。同じ親がいないためだと思うので、試してみました:
$('#reponse137-3').prev("tr").next(".error")
どのようにできるのか ?