2012-09-13 24 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

:)。不要忘記標記爲答案或投票,這有助於 –

相關問題