Reputation: 452
Okay, so i have:
<div class="catergory">
<div class="title">CATEGORY TITLE</div>
<div class="listing">
CODE FOR LISTINGS
</div>
</div>
What i am trying to do, is have it so when you click the CATEGORY TITLE, the LISTINGS div slides down, My problem is, is how do i select that div when i have put a click event on CATEGORY TITLE
My JQuery code is:
$('.title').click(function(){
$('.category > .listings',this).toggleSlide('slow');
});
Now, I know the problem is something with my way of selecting the correct element..
any ideas?
Thanks Neil
Upvotes: 1
Views: 68
Reputation: 3944
$('.title').click(function(){ $(this).next('.listing').slideToggle('slow'); });
Upvotes: 1
Reputation: 905
Try adding the code in $(document).ready() function as the Jquery code can be executed only after jquery is loaded..
Upvotes: 0
Reputation: 490283
$('.title').click(function(){
$(this).next('.listing').slideToggle('slow');
});
The method is also slideToggle()
, not toggleSlide()
.
Upvotes: 3