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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:07:39+00:00 2026-06-01T15:07:39+00:00

I have a situation where I have nested toggle statements in jQuery. I have

  • 0

I have a situation where I have “nested” toggle statements in jQuery.

I have a bunch of selects that allow a user to set a day as open or closed.

I then have a select that allows a user to show details about all the days. Details are hidden by default (this is causing my problem).

If a user sets a day to closed I don’t want to display that day when the user selects to display details for all days. Eg. if monday is set to closed and the rest of the week is open and the user selects “display details” it would show the details for all days except Monday.

This works fine if I start with all the details showing (you can hide and show the details and closed days are not displayed). But by default the details are hidden and if a user sets some days to closed and then displays the details it displays the details for all days, even the closed ones.

Is there an easy way to persist the “nested” toggle when the toggle for the containing div is changed?

I have put together a crude example of the sort of situation in this jFiddle.

http://jsfiddle.net/yTt3t/16/

Thanks for any assistance.

  • 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-01T15:07:40+00:00Added an answer on June 1, 2026 at 3:07 pm

    Indeed, the problem is that the parent element of the elements you change the visibility of is initially hidden. I assume that jQuery performs some optimization to avoid unnecessary CSS and DOM changes.

    It works though if you pass a boolean to .toggle() [docs], which, IMO, is better anyway, it ensures that the state of the element is always correct:

    $("#monday_select").change(function(){
        $("#monday_details").toggle(this.value === 'Open');
    });
    
    $("#tuesday_select").change(function(){
        $("#tuesday_details").toggle(this.value === 'Open');
    });
    

    The argument controls whether the element should be shown (true) or hidden (false).

    DEMO

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

Sidebar

Related Questions

I have situation where a user can manipulate a large set of data (presented
I have a tricky CSS situation here. Basically I have nested span tags that
Here is the situation. I have some ViewModels that contain nested complex model types.
I have situation, where running a query that filters by an indexed column in
I have situation like this: user submits form with action='/pay' in '/pay' I have
We have situation where say we have four engineers that are working on software
The situation I have is that I'm querying MongoDB with a string for a
In a legacy database I have to work with nested tables that are associated
I have a project that has a fairly complicated, nested (references calling the referenced
I have a situation where I need to access an object that has been

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.