Francesco
Francesco

Reputation: 25

Bootstrap-select background color when an option is selected

In my SELECT when I select an option only the inner part becomes yellow. I would like the whole select field to turn yellow.

This is my code:

.bootstrap-select.btn-group .dropdown-toggle:not([title=""]) .filter-option {
      background-color: yellow !important;
}
<select class="selectpicker form-control" data-size="40px" data-width="210px" 
    style="height: 80px" data-live-search="true" data-none-Selected-Text="" 
    data-hide-disabled="true" data-container="body" name="mittente_nucleo" 
    id="mittente_nucleo">
    <option></option>
    <option>1</option>
    <option>2</option>
</select>

JSFiddle

Upvotes: 2

Views: 1839

Answers (1)

lisandro
lisandro

Reputation: 506

You can change the background color with an jQuery event

$('#mittente_nucleo').on('change', function(){
           var selected = $('#mittente_nucleo option:selected').val();
           var element = $('button[data-id="mittente_nucleo"]');
           element.css("background-color", "yellow");
});

JSFiddle https://jsfiddle.net/yrtd7oa4/

Upvotes: 1

Related Questions