Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 992615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:17:45+00:00 2026-05-16T06:17:45+00:00

I was wondering if someone could work this one out as I’ve been trying

  • 0

I was wondering if someone could work this one out as I’ve been trying for 40 mins now and this shouldn’t be so difficult.

I have some nested divs like so:

<div>
<div>
Some info - <a href='#' class='slick-toggle'>[more info]</a>
    <div class='slickbox'>
        <div>
        More Content...
            <a href='#' class='slick-toggle2'>see full XML reply</a><br />
            <div class='slickbox2'>
                    <div class='xmlOutput'>
                       more content from XML source
                    </div>
            </div>
        </div>
    </div>
</div>

Now what I want to happen is when the link with the class “slick-toggle” is clicked the Div with the class “slickbox” is either hidden or show. Within this Div I have other link with the class “slick-toggle2” when this is clicked I want the div with the class “slickbox2” to be hidden or shown (when the page is loaded both these divs are hidden). So you can only toggle “slick-toggle2” if “slick-toggle” is being show. This should be easy, however the toggle only works for the first DIV. Can anyone see what’s wrong with my jQuery

  $(document).ready(function() {

        $('.slickbox').hide();
        $('.slickbox2').hide();

        $('a.slick-toggle2').click(function() {

             $(this).next("div.slickbox2").toggle(400);
            return false;
        });

        $('a.slick-toggle').click(function() {

            $(this).next("div.slickbox").toggle(400);
            return false;
        });

    });

can anyone see where I’m going wrong? I think I’m going mad?

PLEASE NOTE THAT I’ve Taken the A from the hyperlink out of the code as it was getting blocked?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T06:17:46+00:00Added an answer on May 16, 2026 at 6:17 am

    It’s because the very next element is a <br />, so instead of this:

    $(this).next("div.slickbox2").toggle(400);
    

    You need this:

    $(this).nextAll("div.slickbox2:first").toggle(400);
    

    .next() gets the very next element only if it matches the selector. .nextAll() goes through all following siblings, and you’re getting the :first one that matches.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I ran across this and was wondering if someone could explain why this works
I saw this tip in another question and was wondering if someone could explain
I am wondering if someone can help me figure out the best approach to
I saw this keyword for the first time and I was wondering if someone
I was wondering if someone could help me with creating a while loop to
I was wondering if someone could help with i jQuery plugin. Basically what I
I am wondering if someone can put a bit of an authoritative reference summary
I was wondering if someone would be able to help me write a CQL
I'm wondering if someone has already built a system for threaded comments (for lack
What im wondering how to do is when someone edits a list item and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.