Jump to content

jQuery next help


c_pattle

Recommended Posts

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. 

Link to comment
Share on other sites

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? 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.