mercredi 24 octobre 2018

How to make only one checkbox is checkable

As you the code below, my checkbox is like button. I want to make it only one is checkable. For now, Checkbox button change color when is clicked and all buttons are checkable at the same time.

PS. I want to make my checkbox button only is checkable with same effect now(when user click the button

    <div class="col-4">
     <label class="btn btn-primary btn-block">
      <input type="checkbox" name="Categories" value="1" /> check1 </label>`
</div>

     <div class="col-4">
     <label class="btn btn-primary btn-block">
      <input type="checkbox" name="Categories" value="1" /> check1 </label>
</div>

 $('label.btn').on('click','input', function(){
   e.stopPropagation();

   $(this).attr('checked', !$(this).attr('checked'));
   $(e.target).closest('label').toggleClass('btn-flat');
 });

Please help me to solve this simple question. Thank you




Aucun commentaire:

Enregistrer un commentaire