Hey there, I'm new here so please forgive any mistakes I might make or if I break any etiquette rules!
I'm trying to create some cool buttons for radio inputs on a form using field yields. The idea is to have them start off in grayscale and then turn to color when hovered over or selected.
I've tinkered with some code I found here to make it work the way I want, even though I haven't used jQuery before. The code below actually does what I need it to do.
What I need now is for the script to also add the .active class to another element (the label with the class .icon).
Below you'll find the code I'm currently using.
CSS
(CSS code)
jQuery
(jQuery code)
HTML
(HTML code)
Right now, the script adds the .active class to the element with the class #option - but I also want it to apply this to #icon.
I tried rewriting this using parent/child relationships, but it caused issues with the functionality of the checked radio button and applied the class to every div element instead.
(Revised JavaScript code attempt)
I attempted to add:
$("#ICON").addClass("active") or .removeClass
to the relevant parts of the "if/else" statements; however, it doesn't seem to be working.
I am confident that the solution is simple, I'm just feeling a bit overwhelmed after staring at this for so long!