开发者

Jquery selecting problem

开发者 https://www.devze.com 2023-03-06 22:53 出处:网络
Okay, so i have: <div class=\"catergory\"> <div class=\"title\">CATEGORY TITLE</div> <div class=\"listing\">

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..

0

精彩评论

暂无评论...
验证码 换一张
取 消