I want to style checkboxes of bootstrap-multiselect plugin. Basically I want to add a class to label of selected checkbox. I can get the selected value this way but couldn't figure out how to target the checkbox.
<label class="checkbox">
<input type="checkbox" value="red">Red
</label>
$('select').multiselect({
onChange: function(element, checked) {
var colors = $('select option:selected');
$(colors).each(function(){
$(this).parent().addClass('label-selected');
});
}
});
EDIT: The only way I found is to edit the plugin like that:
if (this.options.selectedClass) {
if (checked) {
$target.closest('li').addClass(this.options.selectedClass);
$target.closest('li label').addClass('label-selected'); //ADDED THIS LINE
}
else {
$target.closest('li').removeClass(this.options.selectedClass);
$target.closest('li label').removeClass('label-selected'); //ADDED THIS LINE
}
}