I am setting up an RSForm! Pro form using Radio buttons, but I want to hide the radio buttons input and use the label for the selection, the HTML for the question is:
<div class="rsform-block rsform-block-question">
<div class="formControlLabel">This is the question...?</div>
<div class="formControls">
<div class="formBody">
<p class="rsformVerticalClear">
<input type="radio" id="Question0" value="First Answer" name="form[Question]">
<label for="Question0">First Answer</label>
</p>
<p class="rsformVerticalClear">
<input type="radio" id="Question1" value="Second Answer" name="form[Question]">
<label for="Question1">Second Answer</label>
</p>
<p class="rsformVerticalClear">
<input type="radio" id="Question2" value="Third Answer" name="form[Question]">
<label for="Question2">Third Answer</label>
</p>
</div>
</div>
</div>
Is there anyway I can do this with jQuery?
Through CSS, I want to change the background of the selected label (when clicked on), the input radio button changes, but I can't work out how to change the label to active/focus.
I think the following should work, but it doesn't seem to, as the label doesn't have a class associated with it.
$("input:radio[name='form[Question]']").change(function(){
$("label").removeClass("selected");
$("label[for='" + this.id + "']").toggleClass("selected", this.checked);
});
Any ideas please?