How do I dynamically change the color (background and text) of a single select menu in jQuery Mobile, without affecting other elements of the same class?
I’ve tried several ways, including:
$('#select').css({color:#000});
and
$('#select').removeClass('ui-btn-up-a').addClass('custom-class');
I’ve also tried adding a refresh after it to no avail:
$('#select').selectmenu('refresh');
I’m trying to change the color based on the selected value, so I’m placing the code within the change event of the select menu like so
$("#select").live("change", function(event, ui) {
...
}
My HTML is as follows:
<select name="select" id="select">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
Any help on changing the text color or background color is appreciated!
You can do this in this way:
Let me know if that helps