I am looking to update the header color based on the selected option in a drop-down menu. For example, if option 1 is chosen, the data-background-color will switch to green.
HTML:
<div class="card-header" data-background-color="blue" style="position: relative; padding:25px;">
<h4 class="title" style="font-family: 'Josefin Sans', sans-serif;">
<b>Heading</b>
</h4>
</div>
<div class="col-md-3 col-sm-3 col-xs-6">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">account_balance</i>
</span>
<select type="text" class="form-control validate" id="optionSelect">
<option value="-1">Select Shift</option>
<option style="border-left-color:#2ecc71;" value=1>DAY</option>
<option style="border-left-color:#3498db;" value=2>NIGHT</option>
<option style="border-left-color:#f1c40f;" value=3>AFTERNOON</option>
</select>
</div>
</div>
</div>
Jquery
$('#optionselect').on('change', function() {
var shift = $('#optionselect').val();
if (shift === 'DAY') {
$('#ftagHeader').css({
'background-color': 'green !important'
});
}
});
The data-background-color attribute will be adjusted based on the selection made in the drop-down menu. Please share any insights on how this can be achieved. Thank you!