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

  • Home
  • SEARCH
  • 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 8755123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:47:05+00:00 2026-06-13T13:47:05+00:00

I am having some issues when i am trying to work with slidetoggle property

  • 0

I am having some issues when i am trying to work with slidetoggle property in jquery.
What i would like to accomplish is:

  • i have a parent div with a dynamic number of children divs.
  • when the page is loaded the first div is toggled (open).
  • i would like to when i click on one of children divs , the one that i clicked should toggle open and any other which is open to toggle closed.

I’ve tried this:

   $i++;
   $("#items"+ $i).click(function(){
            $("#items'.$i.'-submenu").slideToggle('slow', function() {
                 if ( $("#item'.$i.'s-submenu").is(":visible")) {
                      $("#items'.$i.'").css("border-right","none");
            }
            else
            {
                $("#items'.$i.'").css("border-style","solid solid solid solid");
                $("#items'.$i.'").css("border-right-width","1px");
            }
            });

            return false;
        });

Later edit:

The HTML looks like:

<div class="item">Click here </div>
<div class="content">There it goes the hidden content</div>
<div class="item">Click here </div>
<div class="content">There it goes the hidden content</div>
<div class="item">Click here </div>
<div class="content">There it goes the hidden content</div>
<div class="item">Click here </div>
<div class="content">There it goes the hidden content</div>
<div class="item">Click here </div>
<div class="content">There it goes the hidden content</div>
<div class="item">Click here </div>
<div class="content">There it goes the hidden content</div>
<div class="item">Click here </div>
<div class="content">There it goes the hidden content</div>
<div class="item">Click here </div>
<div class="content">There it goes the hidden content</div>
 .....................
  • 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-06-13T13:47:07+00:00Added an answer on June 13, 2026 at 1:47 pm

    UPDATED USING YOUR HTML

    New jQuery

    $(".item").click(function(e) {
        $(this).next(".content").slideToggle().siblings(".content").each(function(i) {
            if ($(this).is(":visible")) $(this).slideToggle();
        });
    });
    

    New jsFiddle Here


    You could just use jQueryUI accordion, however if you want to do it yourself it is not hard.

    See jsFiddle Here

    The code would be like below:

    Basic HTML Layout

    <div class="item">
        <p class="clickable">Click Here</p>
        <div class="content">
            I'm open!
            <br />
            I'm open!
            <br />
            I'm open!
        </div>
    </div>
    <hr />
    <div class="item">
        <p class="clickable">Click Here</p>
        <div class="content">
            I'm open!
            <br />
            I'm open!
            <br />
            I'm open!
        </div>
    </div>
    <hr />
    <div class="item">
        <p class="clickable">Click Here</p>
        <div class="content">
            I'm open!
            <br />
            I'm open!
            <br />
            I'm open!
        </div>
    </div>
    <hr />
    <div class="item">
        <p class="clickable">Click Here</p>
        <div class="content">
            I'm open!
            <br />
            I'm open!
            <br />
            I'm open!
        </div>
    </div>
    <hr />
    <div class="item">
        <p class="clickable">Click Here</p>
        <div class="content">
            I'm open!
            <br />
            I'm open!
            <br />
            I'm open!
        </div>
    </div>​
    

    a lil CSS

    .content { display: none; }
    .clickable { cursor: pointer; }
    

    Finally some jQuery

    $(".item").click(function(e) {
        $(this).siblings().each(function(i) {
            if ($(this).children(".content").is(":visible")) $(this).children(".content").slideToggle();
        });
        $(this).children(".content").slideToggle();
    });​
    

    ​

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

Sidebar

Related Questions

I'm having some issues with a report I'm trying to create for TFS work
Having some issues getting this MPMoviePlayerViewController to work. I have two sample URLs pointing
I am having some issues getting my JS to work right. I am trying
I'm trying to work with the Zigfu API but I am having some issues.
I'm having some issues trying to insert a query into the database. I have
I am having some serious issues trying to tweak my layout in a table.
I am currently learning C, and am having some issues with trying to make
I am trying to get php's namespace technique down but having some issues here:
I'm trying to get started with twitter4r but I'm having some issues: Why I
I'm trying to convert some VB.net code into C# and having issues trying to

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.