我從數據庫中生成一個表,看起來像這樣的jQuery上點擊同胞選擇
<table id="items">
<thead>
<tr>
<th>Details</th>
<th>Goldmine ID</th>
<th> </th>
</tr>
</thead>
<tbody>
<tr>
<td class="evenrow">This is a test Description generated through UNIT Tests for the category description</td>
<td class="evenrow"><input type="text" value="" id="106" class="gminput"></td>
<td class="butCell evenrow"><button class="saveButton updateitem">Update</button></td>
</tr>
<tr>
<td class="oddrow">This is a test Description generated through UNIT Tests for the category description</td>
<td class="oddrow"><input type="text" value="" id="107" class="gminput"></td>
<td class="butCell oddrow"><button class="saveButton updateitem">Update</button></td>
</tr>
<tr>
<td class="evenrow">This is a test Description generated through UNIT Tests for the category description</td>
<td class="evenrow"><input type="text" value="" id="108" class="gminput"></td>
<td class="butCell oddrow"><button class="saveButton updateitem">Update</button></td>
</tr>
</tbody>
</table>
我試圖讓輸入框的值和ID由相關行的按鈕返回點擊
至今我曾經試過,但失敗了
$('body').on('click', '.updateitem', function(event) {
event.preventDefault();
$(this).parent().siblings().each(function(index) {
alert(($(this).val()));
});
var par = sib.parent('td');
par.addClass('redBorder');
});
我可以將你的問題總結爲一句話;) – user1534664
作爲一個便箋,它是'.each'。 – pimvdb
@ user1534664就我個人而言,我已經閱讀了整篇文章,並且我希望有足夠的信息來確定需要什麼。 HTML特別有用。 –