I'm working on a Joomla page in which there are rows of 4 radio buttons (labelled A B C and D) displayed down the page as part of a multiple choice test. Each set of radio buttons is in a table. The radio buttons have been replaced by images. Here is the HTML showing part of a row of radio buttons:
input[type='radio'] {
display: none;
}
input[type="radio"] > img:nth-child(2) {
display: none;
}
input[type="radio"]:checked + img:nth-child(2)img:nth-child(1) {
display: none;
}
input[type="radio"]:checked + img:nth-child(2)img:nth-child(1) {
display: inline-block;
}
<table>
<tbody>
<tr>
<form>
<td>
<label>
<input type="radio" name="toeic" class="toeic_p1" value="A" required="required">
<img class="radio_btn" src="/templates/beez_20/images/toeic/unchek_A.png" height="25" width="25">
<img class="radio_btn" src="/templates/beez_20/images/toeic/chek_A.png" height="25" width="25">
</label>
</td>
....
<td>
<label>
<input type="radio" name="toeic" class="toeic_p1" value="D">
<img class="radio_btn" src="/templates/beez_20/images/toeic/unchek_D.png" height="25" width="25">
<img class="radio_btn" src="/templates/beez_20/images/toeic/chek_D.png" height="25" width="25">
</label>
</td>
</form>
</tr>
</tbody>
</table>
I followed, as an example, the code set out here Change image on radio button click using JS or HTML but I've been unable to get it to work. I'm not committed to a pure CSS solution, jQuery would be fine. Any help would be much appreciated. Thanks