vendredi 31 mai 2019

Why I can't checked more than checkboxes?

Using Flask I populated a table and tried to create something which made it possible for clicking in any part of row and "checked" the checkbox input. But I can't checked more than one.

Created a var to check if the input is "checked", if no, checked! if yes, make possible unchecked the box at any part of tr.

  $("table tbody tr").on('click',function(){
    var checked = $("input:checkbox").is(':checked');
    if(checked){
     $("input:checkbox",this).prop('checked', false);
     console.log(checked);      
    }else{
     console.log(checked);
     $("input:checkbox",this).prop('checked', true);
    }

HTML:

<table class="table table-responsive" id="osTable" width="100%" cellspacing="0" align="center">
        <thead align="center">
            <tr>
             <th>#</th>         
             <th>Id</th>        
             <th>Name</th>                                                  
            </tr>
        </thead>
        <tbody>
         
        </tbody>        
    </table>




Aucun commentaire:

Enregistrer un commentaire