I have a small Quiz on a webpage with a table of questions. In each row are two possible answers, each has its own radio button for selection. Now my Problem, i want to make the whole cell clickable and not just the Radio button.
This is the code i came up with, but it only works once per radio button. After the first click, i have to click multiple times to switch the selection.
jQuery(".clickable").click(function(event) {
var x = jQuery("input", this).attr("checked");
jQuery("input", this).attr("checked", !x);
return false;
});
Here is a sample row
<tr class="row_cls" id="quiz_row0">
<td class="clickable" style="border:1px solid #ddd;vertical-align: middle;padding-top:10px;padding-bottom:10px;padding-left:10px;">
<label style="margin-bottom:0px;">
<input type="radio" style="height:20px; width:20px;" class="radio-form-control radio_input1" id="radio_input166" name="quiz_row0" value="Herausforderung" checked="checked">
<span style="font-size: 20px;">Herausforderung</span>
</label></td>
<td class="clickable" style="border:1px solid #ddd;vertical-align: middle;padding-top:10px;padding-bottom:10px;padding-left:10px;">
<label style="margin-bottom:0px;">
<input type="radio" style="height:20px; width:20px;" class="radio-form-control radio_input1" id="radio_input118" name="quiz_row0" value="Macht/ Aufstieg" checked="checked">
<span style="font-size: 20px;">Macht/ Aufstieg</span>
</label></td>
</tr>
I would be really grateful for suggestions!
input", this).attr("checked", !x);have no sense.