如何在点击#first
时访问位于#second
和.glyphicon-pencil
的输入框的相应值,即当我点击.glyphicon时它必须给出值90909 -pencil on <tr>
此处和1000125点击第二个<tr>
<tr id_gl_code="66" class="success">
<td id="first" id_gl_code="66"><input type="text" class="form-control" value="90909"></td>
<td id="second"><input type="text" class="form-control" value="some xyz"></td>
<td id="third"><span id_gl_code="66" class="glyphicon glyphicon-pencil"></span></td>
<td id="fourth"><span id_gl_code="66" class="glyphicon glyphicon-trash"></span></td>
</tr>
<tr id_gl_code="67" class="success">
<td id="first"><input type="text" class="form-control" value="1000125"></td>
<td id="second"><input type="text" class="form-control" value="miscellanious income expenses"></td>
<td id="third"><span id_gl_code="67" class="glyphicon glyphicon-pencil"></span></td>
<td id="fourth"><span id_gl_code="67" class="glyphicon glyphicon-trash"></span></td>
</tr>
答案 0 :(得分:0)
试试这个
$(document).on('click','.glyphicon-pencil',function(){
var first=$(this).parents('tr').find('td:eq(0) input').val()
var second=$(this).parents('tr').find('td:eq(1) input').val()
});