javascript - Bootstrap uncheck checkbox and style -


i have 3 buttons / checkboxes, if click on gets checked, how make other buttons uncheck if click on current one.

https://jsfiddle.net/dtchh/31573/

<div class="btn-group" data-toggle="buttons">     <label class="btn btn-default btn-lg no-border">         <span id="btnpencil" class="glyphicon glyphicon-pencil" aria-hidden="true"></span>         <input type="checkbox" autocomplete="off">     </label>     <label class="btn btn-default btn-lg no-border">         <span class="glyphicon glyphicon-th-large" aria-hidden="true"></span>         <input type="checkbox" autocomplete="off">     </label>     <label class="btn btn-default btn-lg no-border">         <span class="glyphicon glyphicon-th-large" aria-hidden="true"></span>         <input type="checkbox" autocomplete="off">     </label> </div>  btnp = document.getelementbyid(btnpencil)  btnp.addeventlistener('change', function() {     // 1. check current button / checkbox     // 2. uncheck other buttons / checkbox     // bootstrap uncheck / check style ? }); 

you should use radio buttons this, not checkboxes, , style them checkboxes (if prefer look). instead of

<input type="checkbox" autocomplete="off"> 

just use

<input type="radio" autocomplete="off" name="x"> 

and make sure radios have same name attribute.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -