当用户点击div(div在我的专栏'Conversa'中)时,我希望在相应的行中获取我的第一列(称为'Proposta')的值。
我怎么能通过Jquery做到这一点?
我的ASPX
<asp:TemplateField HeaderText="Conversa">
<ItemTemplate>
<div style="width:30px;">
<div id="lblConversa">Conversa</div>
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Ação">
<ItemTemplate>
<%= acao %>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
我的HTML呈现
<table class="StyleGrid" cellspacing="0" border="0" id="grdDetalheProposta" style="border-width:0px;width:100%;border-collapse:collapse;">
<tr class="thGrid" style="color:#000000;background-color:#E2DCD2;height:20px;">
<th scope="col">Proposta</th><th scope="col">Data</th><th scope="col">Valor</th><th scope="col">Comentário</th><th scope="col">Inserido Por</th><th scope="col">Credenciada Proponente</th><th scope="col">Status</th><th scope="col">Conversa</th><th scope="col">Ação</th>
</tr><tr class="EstiloDalinhaGrid" align="center">
<td>208194</td><td style="width:1px;">29/12/2011 14:32:13</td><td>11,11</td><td>Teste 1</td><td>Flávio Oliveira Santana</td><td>Central de Operações</td><td>Andamento</td><td>
<div style="width:30px;">
<div id="lblConversa">Conversa</div>
</div>
</td><td>
</td>
</tr>
</table>
答案 0 :(得分:1)
在点击事件处理程序中,从div
上升到td
,然后返回到同一td
中的第一个孩子tr
:
$('#grdDetalheProposta td > div').click(function() {
var proposta = $(this).closest('td').prevAll('td:first-child').text();
// proposta contains the value of the first td in the same row
});