I'm trying to untoggle the other buttons in the button group when clicking on a button in the group. For example, when a person clicks "E" it toggles the E button on and turns off the others.
I am doing this for multiple different button groups, but each one should be able to have an individual button active, is it also possible to make it work this way?
<div class="btn-group btn-group-toggle">
<button class="btn btn-secondary acroTrained" data-toggle="buttons" autocomplete="off"> T </button>
<button class="btn btn-secondary acroExpert" data-toggle="buttons" autocomplete="off"> E </button>
<button class="btn btn-secondary acroMaster" data-toggle="buttons" autocomplete="off"> M </button>
<button class="btn btn-secondary acroLegendary" data-toggle="buttons" autocomplete="off"> L </button>
</div>
Bootstrap 5 comes with that feature already, you can read more about that on this section of the docs: https://getbootstrap.com/docs/5.0/components/button-group/#checkbox-and-radio-button-groups
EDIT
You can do this with some JavaScript code, you need to store a temp value on the element when click on radio buttons because every time you click on the radio it is set to checked, so we need to know the previous state of the checked attribute so when we click again we can know if the button is
checked(active), if it is, we set tochecked = false.Also, i added the class
.btn-group-unselectableto.btn-groupelement.Here is the JQuery version of this code: