nmyster
nmyster

Reputation: 452

Jquery selecting problem

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

Answers (4)

Xhalent
Xhalent

Reputation: 3944

$('.title').click(function(){ $(this).next('.listing').slideToggle('slow'); });

Upvotes: 1

Archan Mishra
Archan Mishra

Reputation: 905

Try adding the code in $(document).ready() function as the Jquery code can be executed only after jquery is loaded..

Upvotes: 0

Jan Zyka
Jan Zyka

Reputation: 17888

The jQuery method is slideToggle not toggleSlide.

Upvotes: 0

alex
alex

Reputation: 490283

$('.title').click(function(){
    $(this).next('.listing').slideToggle('slow');
});

The method is also slideToggle(), not toggleSlide().

jsFiddle.

Upvotes: 3

Related Questions