I'm new to jQuery, so please excuse me!
I have a PHP function that returns me a blog from a MySQL database; it returns the title, subtitles and contents.
$result = getData(); while($row = mysqli_fetch_array($result)) { extract($row); ?> <div class="headline"><?php echo $headline ?></div> <div class="subtitle"><?php echo $subTitle ?></div> <div class="content"><?php echo $content ?></div> <?php }
While three records are displayed. I have jQuery that hides content and expands it when the header is clicked using the nextUntill and .slideToggle method in the content.
$(".content").hide(); $(".headline").click(function(){ $(this).nextUntil(".headline").slideToggle(500); });
my problem is that slideToggle is executed on each div until the next title, which includes subtitles. Therefore, when the title lights up, the content is displayed, but the title disappears.
I canβt just select the content for the slide, as it will show all three sections of the content that will be displayed.
Is there a way to exclude subtitles between the title and the content?
Thanks in advance!
source share