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 6759233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:54:41+00:00 2026-05-26T13:54:41+00:00

I got an menu with different slidetoggles in it. the javascript looks like this:

  • 0

I got an menu with different slidetoggles in it. the javascript looks like this:

$('.toggler').live('click',function(){
              $(this).parent().children().toggle();  //swaps the display:none between the two spans
              $(this).parent().parent().find('.toggled_content').slideToggle();  //swap the display of the main content with slide action
              $(this).parent().parent().find('.toggled_content2').css('display', 'none');
              $(this).parent().parent().find('.div2').css('display', 'none');
              $(this).parent().parent().find('.ap2').css('display', 'block');
              $(this).parent().parent().find('.toggled_content3').css('display', 'none');
              $(this).parent().parent().find('.div3').css('display', 'none');
              $(this).parent().parent().find('.ap3').css('display', 'block');
              $(this).parent().parent().find('.toggled_content4').css('display', 'none');
              $(this).parent().parent().find('.div4').css('display', 'none');
              $(this).parent().parent().find('.ap4').css('display', 'block');

          });

Now u can see that once i click an .toggler he sets certain area’s to display:none and some to display:block. But what would be more perfect if i can replace this part of code:

$(this).parent().parent().find('.toggled_content2').css('display', 'none');

To some code that checks if the block is open and so yes then it slides to close it. I don’t know if this is possible but it would look nicer if it does.

Thanks in forwards!

Here is the HTML:

                        <div id="spacerouter"><div id="spacer"><div id="spacerin"></div><div id="spacerinr"></div></div></div>
                <div class='toggleHolder'>
                    <div id="company" class='toggler ap1'>
                        <div id="companysiton"></div>
                            <div id="companyname">
                                <h1>Siton Suzenaar</h1>
                                <h2>Hyundai / Opel / Chevrolet</h2>
                            </div><!-- companyname -->
                    </div><!-- company -->
                    <div id="company2" class='toggler div1' style='display:none;'>
                        <div id="companysiton"></div>
                            <div id="companyname">

                                <h2>Hyundai / Opel / Chevrolet</h2>
                            </div><!-- companyname -->
                    </div><!-- company -->
                </div><!-- toggleHolder -->
                <div class='toggled_content' style='display:none;' id="toggled_content">
                    <h3>



                    </h3>
                    <h3>
                    <a href="mailto:mail@mailhost.nl">mail@mailhost.nl</a><br />

                    </h3>
                </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-05-26T13:54:42+00:00Added an answer on May 26, 2026 at 1:54 pm

    You could use the visible & hidden selectors and add a common class to all your elements that need to be toggled.

    $(this).parent().parent().find('.commonClass:visible').css('display', 'none');
    
    $(this).parent().parent().find('.commonClass:hidden').css('display', 'block');
    

    Or better yet

    $(this).parent().parent().find('.commonClass').slideToggle()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got menu items that look like this <ul> <li>Item1<span class=context-trigger></span></li> <li>Item2<span class=context-trigger></span></li> <li>Item3<span
I've got a css menu like this: <ul> <li><a>Item1</a></li> <li><a>Item Two</a></li> <li><a>Item C</a></li> <li><a>A
I got a problem like this (this is html/css menu): Eshop | Another eshop
I've got a menu, that is something like this: <ul id=menu_cat> <li><a class=cat1 href=#>category
I've got a simple dropdown menu that I want to hide whenever you click
I've got this menu wich is setup inline and has dropdowns. The inner ul
So I'm experiencing problem - I got a function, when someone clicks a menu,
I've got menu in my ASP MVC project, and can when I use <li><%=
I've got a menu in Python. That part was easy. I'm using raw_input() to
I've got a menu that contains, among other things, some most-recently-used file paths. The

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.