Hi. I'm stuck on something. I have a form that has fields which only show when a particular radio button is checked. This is easy enough to when someone is filling out the form for the first time using the following code.
HTML
<fieldset id="question">
<legend>This is my question</legend>
<label for="answerYes">Yes</label>
<input name="answer" id="answerYes" type="radio" value="1" />
<label for="answerNo">No</label>
<input name="answer" id="answerNo" type="radio" value="0" />
</fieldset>
jQuery
$("#subQuestion").hide();
$("#answerYes").click(function() {
$("#subQuestion").show();
});
$("#answerNo").click(function() {
$("#subQuestion").hide();
});
This logic breaks down though when someone comes back to the form to edit it. In that case, the fields are prepopulated so the click function doesn't exist. How can I use jQuery to show #subQuestion if #answerYes is checked when the page loads.
Thanks very much! Marcus