[jQuery] Re: Grouping Definition list items
Thanks, that worked perfectly. On May 28, 5:11 am, Scott Sauyet <[EMAIL PROTECTED]> wrote: > macgregor wrote: > > I have a survey marked up with a definition list like so: > > > [ ... ] > > Question 2 > > Answer 1 > > Answer 2 > > Answer 3 > > > > > > > > > > > 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
[jQuery] Re: Grouping Definition list items
macgregor wrote: I have a survey marked up with a definition list like so: [ ... ] Question 2 Answer 1 Answer 2 Answer 3 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
[jQuery] Re: Grouping Definition list items
Have you tried using .next() ? Something along these lines (untested): $('dd.comments input[type="radio"]').toggle( function(){ $(this).next('dd.feedback').show(); }, function(){ $(this).next('dd.feedback').hide(); } }); - jason On May 27, 3:57 pm, macgregor <[EMAIL PROTECTED]> wrote: > I have a survey marked up with a definition list like so: > > > Question 1 > Answer 1 > Answer 2 > > > > Question 2 > Answer 1 > Answer 2 > Answer 3 > > > > > > 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.