Hi all,
I am trying to create an expandable definition list with two levels. Here is my code so far -
<dl>
<dt class="section"><a href="http://">Open the next definition list</a></dt>
<dl>
<dt class="solution"><a href="http://">Solution 1</a></dt> <!-- Click this to reveal the next three dd -->
<dd><a href="http://">Product Name #1</a></dd>
<dd><a href="http://">Product Name #2</a></dd>
<dd><a href="http://">Product Name #3</a></dd>
<dt class="solution"><a href="http://">Solution 2</a></dt> <!-- Click this to reveal the next three dd -->
<dd><a href="http://">Product Name #1</a></dd>
<dd><a href="http://">Product Name #2</a></dd>
<dd><a href="http://">Product Name #3</a></dd>
</dl>
</dl>So I have a link which is the dt with the class section. The underneath that I have another dl which expands when I click the dt with the class section.
What I can’t figure out is how to expand the dd elements after each dt with solution class. I only want to target the dd elements the immediately come after that dt but only up until the next dt.
$("dt.section").click(function(){
$(this).siblings().toggle();
$(this).toggleClass("open");
return false;
});
$("dt.solution").click(function(){
$(this).nextAll().toggle();
$(this).toggleClass("open");
return false;
});The first bit opens and closes the dt ok I can’t get my head around how to target all dd only up until the next dt. nextAll opens all dd, next just the next dd.
Any help?