To change the background color of a radio button in JavaScript, you need to select the radio button element and set its background-color property using the style object. Here's an example:
150 chars4 lines
166 chars9 lines
index.tsx306 chars11 lines
In the example above, we add an event listener to the radio button that listens for the 'change' event. When the radio button is checked, we set its parent element's background color to '#f0f0f0'. When it's unchecked, we set the background to 'none'.
Note that in the CSS code, we select the label element adjacent to the radio button using the '+' selector. This allows us to target the label when the radio button is checked, and style it accordingly.
gistlibby LogSnag