c_pattle Posted January 14, 2011 Share Posted January 14, 2011 I have a link that when pressed I want it to do a slideToggle on the next element with the class of ".article_info". I want to do this because there are lot of elements with this class so I only want it to perform this on the next one. I have tried lots of things but can't get this to work, it just does nothing. Here is my code at the moment $('.article_toggle').click(function () { $(this).nextAll(".article_info").slideToggle(); return false; }); Also here is an example of my HTML. <div class="article"> <div class="article_header"> <h3>Header</h3><p><a class="article_toggle" href="">Toggle</a></p> </div> <p class="content">Content description</p> <div class="article_info"> <p>Article info line 1</p> <p>Article info line 2</p> <p>Article info line 3</p> </div> </div> Thanks for any help. Quote Link to comment https://forums.phpfreaks.com/topic/224469-jquery-next-help/ Share on other sites More sharing options...
brianlange Posted January 15, 2011 Share Posted January 15, 2011 The nextAll function works on sibling objects. Because the link is inside of a containing element it is not a sibiling of the divs with a class of article_info. However even if you restructure the html so the elements are siblings, all of the article_info divs will be affected. There's probably a better way to accomplish what you are trying to do. Can you post a url? Quote Link to comment https://forums.phpfreaks.com/topic/224469-jquery-next-help/#findComment-1159614 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.