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 sele开发者_如何学运维ct 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
$('.title').click(function(){
$(this).next('.listing').slideToggle('slow');
});
The method is also slideToggle()
, not toggleSlide()
.
jsFiddle.
$('.title').click(function(){ $(this).next('.listing').slideToggle('slow'); });
The jQuery method is slideToggle not toggleSlide.
Try adding the code in $(document).ready() function as the Jquery code can be executed only after jquery is loaded..
精彩评论