macgregor wrote:
I have a survey marked up with a definition list like so:
<dl> [ ... ]
<dt>Question 2</dt>
<dd>Answer 1<input type="radio" /></dd>
<dd>Answer 2<input type="radio" /></dd>
<dd class="comments">Answer 3<input type="radio" /></dd>
<dd class="feedback">
<textarea></textarea>
</dd>
</dl>
Is there any way to select the dd elements for a particular dt? I
would like to be able to show/hide the textarea when the radio button
inside dd.comments is clicked/selected.
It seems as though there should be something simpler, but I think this
might work:
$("dd.feedback textarea").hide();
$("dd.comments input[type=radio]").change(function() {
$(this).parents("dd").nextAll("dd.feedback:first").find("textarea").show();
});
$("dd:not(.comments) input[type=radio]").change(function() {
$(this).parents("dd").nextAll("dd.feedback:first").find("textarea").hide();
});
Good luck,
-- Scott