I have a few radio buttons replaced with images. I have a second set of images I'd like the original ones to change to when a certain button is selected.
HTML
<label class="item">
<input type="radio" value="10" name="size" required="required"/>
<img src="./images/10.png"/>
</label>
...
CSS
label.item > input {
visibility: hidden;
position: absolute;
}
In this case, the image is 10.png
. I'd like it to change to 10S.png
when selected, but revert back to 10.png
when another option is selected.
My best idea was to use JS to append an S
to the end of the image path onclick, but reverting back proved troublesome. Is there a strictly HTML/CSS way to do it, or is JS a must? All images used for the radio buttons are in the form #.png
from 1-10, and the updated images are #S.png
from 1-10 (ie. 2.png will become 2S.png, etc).
I'd rather not use JQuery if possible and I'm hoping for a solution with the most browser compatibility.