我从数据库中生成一个表,看起来像这样的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特别有用。 –