Answer the question
In order to leave comments, you need to log in
How to change class on checkbox click?
Good afternoon, tell me please.
I want to wrap the checkboxes in a Lable, how to make it so that when the checkbox is selected, the lable changes from the default label-primary to label label-success and back if the selection is removed from the checkbox. Thank you.
<span class="label label-primary"><input type="checkbox">Не выделено</span>
<span class="label label-success"><input type="checkbox">Чекбокс выделено</span>
Answer the question
In order to leave comments, you need to log in
Can be done on pure css, more precisely on sass with the sass version of the bootstrap
connected through the checkbox, you can influence neighboring elements
codepen.io/bingo347/pen/EKXdPB
or mb lable itself can be made as a checkbox when one color is not selected, another is selected.
If the class change is necessary for styling, then the :checked pseudo-class can be
used
css for the selected checkbox
input[type="radio"]:checked + span {
// styles
}
If for other purposes, then through javascript or php
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question