0

テーブル行のチェックボックスを1つだけ無効にするにはどうすればよいですか?phtmlファイルにfor条件があります。私のhtmlにはtdチェックボックス用のチェックボックスが1つありますが、1つのチェックボックスをクリックすると、テーブル内のすべてのチェックボックスが無効になります。以下は、チェックボックス付きのforループです。

<?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); 
}); 
4

2 に答える 2

1

これをに変更します

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

これ

 $('.chkAll').change(function() {
        $(this).attr('disabled', this.checked); 
 }); 
于 2012-09-13T12:57:15.420 に答える
0
$('.chkAll').change(function() {
        $(this).attr('disabled', this.checked); 
    }); 
于 2012-09-13T12:56:45.340 に答える