我希望点击Add
时td
的{{1}},Javascript / JQuery会从定位的textarea中选择此tr
和id
紧接着那个id [不是所有textarea] .....
HTML
val()
JS
<tr>
<td>A</td>
<td>£ 10</td>
<td><b id='1' class='btn'>Add</b></td>
</tr>
<tr>
<td>
<div class='form-group'>
<label>Add Note:</label>
<textarea class='form-control'></textarea>
</div>
</td>
</tr>
<tr>
<td>B</td>
<td>£ 10</td>
<td><b id='2' class='btn'>Add</b></td>
</tr>
<tr>
<td>
<div class='form-group'>
<label>Add Note:</label>
<textarea class='form-control'></textarea>
</div>
</td>
</tr>
<tr>
<td>C</td>
<td>£ 10</td>
<td><b id='3' class='btn'>Add</b></td>
</tr>
<tr>
<td>
<div class='form-group'>
<label>Add Note:</label>
<textarea class='form-control'></textarea>
</div>
</td>
</tr>
答案 0 :(得分:1)
将note
更改为:
var note = $(this).closest('tr').next().find('textarea').val();