<div class="tbs_icontainer" style="height: 415px;">
<TABLE class=tbs_table cellSpacing=0 cellPadding=0>
<THEAD class=tbs_head>
</THEAD>
<TBODY class=tbs_body>
<TR style="BACKGROUND-COLOR: #ffffff" class=tbs_tr jQuery1368094469282="11">
<TD style="WIDTH: 20px" class=tbs_td><INPUT class=search value=0 type=checkbox name=search jQuery1368094469282="12"></TD>
**<TD class=tbs_td>00-0227101-</TD>
<TD class=tbs_td>1</TD>**
<TD class=tbs_td> </TD>
<TD class=tbs_td>Medak</TD>
<TD class=tbs_td>02/27/2013</TD>
<TD style="BORDER-RIGHT: medium none" class=tbs_td>02/01/2013</TD></TR>
<TR style="BACKGROUND-COLOR: #ebf4fa" class=tbs_tr jQuery1368094469282="13">
<TD style="WIDTH: 20px" class=tbs_td><INPUT class=search value=1 type=checkbox name=search jQuery1368094469282="14"></TD>
<TD class=tbs_td>01-123456789-</TD>
<TD class=tbs_td>1</TD>
<TD class=tbs_td>2010 Acura CSX 4D Sed</TD>
<TD class=tbs_td>Insured Ln, Insured Firstname</TD>
<TD class=tbs_td>03/05/2013</TD>
<TD style="BORDER-RIGHT: medium none" class=tbs_td>03/05/2013</TD></TR>
<TR style="BACKGROUND-COLOR: #ebf4fa" class=tbs_tr jQuery1368094469282="17">
<TD style="WIDTH: 20px" class=tbs_td><INPUT class=search value=3 type=checkbox name=search jQuery1368094469282="18"></TD>
**<TD class=tbs_td>01-4444445-</TD>
<TD class=tbs_td>1</TD>**
<TD class=tbs_td>2012 Acura RL 4D Sed</TD>
<TD class=tbs_td>Insured Last Name, Insured First Name</TD>
<TD class=tbs_td>03/06/2013</TD>
<TD style="BORDER-RIGHT: medium none" class=tbs_td>03/06/2013</TD></TR>
在上面的DIV中,我要求点击按钮时我必须选择前两个TD的值(以粗体突出显示),只有在选中了chechbox时才会这样做。我不知道怎么做?< / p>
单击按钮我正在调用jquery方法: -
<fw:Button runat="server" ID="btnSelect" Text="Select" OnClientClick="getSelectedClaims();" />
function getSelectedClaims()
{
$('.tbs_table').each(function ('.search:checkbox:checked') {
//What to do to select values from first two TDs after first TD if checkbox is checked
});
}
答案 0 :(得分:2)
尝试
$('.tbs_table tr').has('.search:checkbox:checked').each(function(){
var $tr = $(this);
var val1 = $tr.find('td').eq(1).text();
var val2 = $tr.find('td').eq(2).text();
//do something
});
演示:Fiddle
答案 1 :(得分:1)
我已经在我的在线测验引擎中解决了类似的问题(请参阅演示:http://www.webinfocentral.com),如以下jQuery代码段中所示:
var _rows = $(this).find('tr');
for (i = 0; i < _rows.length; i++) {
// find out if checkbox is checked
_checked = $(_rows[i]).find('input:checkbox').is(':checked');
}