2012-09-13 26 views
0

如何禁用表格行中的单个复选框?我有一个phtml文件的条件。我的html有一个td为我的复选框,但如果我点击一个复选框,它会禁用表中的所有复选框。下面是我的for循环复选框。jquery禁用表格中的所有复选框

<?php  
    foreach($this->rows as $record) 
    {   
     echo "<tr>";  
     echo "<td >". $record['firstname'] . "</td>";  
     echo "<td>".$record['advicetoowners'] . "</td>";   
     echo"<td>".$record['customdata'] . " <br /> ".$record['reservation'."</td>"; 
     ?> 

     <td class='stylecontent'width='2' > 
      <input type="checkbox" name="seen" value="" class='chkAll'/> 
     </td>  
     <?php 
    }   
?> 

我jQuery是:

$('.chkAll').change(function() { 
    // This disables all the check box in a table.How to make it to disable only one 
    $('input:checkbox').attr('disabled', this.checked); 
}); 

回答

1

改变这

$('.chkAll').change(function() { 
     $('input:checkbox').attr('disabled', this.checked); 
}); 

$('.chkAll').change(function() { 
     $(this).attr('disabled', this.checked); 
}); 
+0

超级帮助我。谢谢你,亲爱的弟弟 – Indira

+0

欢迎@Indira – rahul

0
$('.chkAll').change(function() { 
     $(this).attr('disabled', this.checked); 
    }); 
+0

为me.thank你我亲爱的兄弟超级帮助 – Indira

+0

:)。不要忘记标记为答案或投票,这有助于 –

相关问题