Skip to content
Advertisement

Is it possible to dynamically change the color of a dropdown or change list item color when a radio option is selected in Javascript/JQuery?

I have code that allows me to select a radio option, say, ‘Work’, and have the dropdown box automatically select ‘Work’ in response. But is it possible to go further and to select the radio option ‘Work’, and have the ‘Work’ dropdown be selected and also change to blue, for instance. And green for ‘Grocery’, red for ‘Chores’, etc. Maybe even go further than that and have the subsequent task list items also color-coded based on Category?

JavaScript
JavaScript

Advertisement

Answer

Yes is possible 🙂 I add an if for every choise and add class and remove other.

JavaScript
JavaScript
JavaScript
Advertisement