Thankyou very much Charlie, for the .find modfication, the working
example and the explanation of what is and what isn't a child or
sibling

Well done!

Thankyou from Josh H

On Jun 8, 8:16 pm, Charlie <charlie...@gmail.com> wrote:
> the reason it doesn't work is  ul.links isn't a sibling of the li that click 
> occurs on, it is nested inside that li and therefore is a child. In the 
> Learning jQuery example, the div's that are being opened and closed are 
> siblings of the h3 that is being clicked
> .next() will look for a sibling, not a child.
> you can make it work by changing the 2 var's to look for ul.links as children
>         var $nexto = $(this).find(".links");
>        
>         var $visibleSiblings = $(this).siblings().find('.links:visible');
> working examplehttp://jsbin.com/efazo/
> followerofjesus wrote:Hello, I was wondering how to 
> makehttp://www.learningjquery.com/2007/03/accordion-madnessby Karl, work with 
> an unordered lis instead of divs. I tried the below but did not work. I think 
> what I have done here ('.links:visible'); looks plain wrong (I can't put a 
> class or an Id in there right??) $(document).ready(function() { 
> $('.links').hide(); $('.category').click(function() { var $nexto = 
> $(this).next(); var $visibleSiblings = $nexto.siblings('.links:visible'); if 
> ($visibleSiblings.length ) { $visibleSiblings.slideUp('fast', function() 
> {$nexto.slideToggle('fast'); }); } else { $nexto.slideToggle('fast'); } }); 
> }); The HTML: <ul> <li class="category">Web Packages and Services <ul 
> class="links"> <li><a href="somewhere.html">How do you do</a></li> <li><a 
> href="somewhere.html">How are you going</a></li> <li><a 
> href="somewhere.html">Have a good day</a></li> <li><a 
> href="somewhere.html">Testing testing</a></li> <li><a 
> href="somewhere.html">Good day to you</a></li> </ul> </li> <li 
> class="category">Web Packages and Services <ul class="links"> <li><a 
> href="somewhere.html">How do you do</a></li> <li><a href="somewhere.html">How 
> are you going</a></li> <li><a href="somewhere.html">Have a good day</a></li> 
> <li><a href="somewhere.html">Testing testing</a></li> <li><a 
> href="somewhere.html">Good day to you</a></li> </ul> </li> </ul>

Reply via email to