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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:02:40+00:00 2026-06-02T04:02:40+00:00

I am trying to have a category index of expandable/colapsable elements, and when the

  • 0

I am trying to have a category index of expandable/colapsable elements, and when the user clicks a category it is rebuilt with an id of ‘catSel’.

The problem is when the user clicks an <li> and the ‘catSel’ id is added to it, it will still be affected by the .hide(); and I don’t want it to be. I should note that I have it working if the user clicks a <ul> element it will not be affected by the .hide();

What I really want is that if a <ul> or any of its <li> elements have the id of ‘catSel’ that that <ul> will not be affected by the .hide();

Here is the code and a sample link, you can see how the <ul> is not expanded but one of its <li> children has an id of ‘catSel’

EDIT:
Sorry for the bad explanation, I still can’t explain it very well but I want it so that if a <ul> or one of its child <li> elements has an id="catSel" that it will not be affected by $('ul.catList:not(.level-0) li:has(ul):not(#catSel)').children('ul').hide();.

UPDATE:

I added this code:

// If an elementwith its id="catSel" show all of its parents and also update the parents class

    $('#catSel').parents().show();
    $('#catSel').parents().removeClass('plusimageapply');
    $('#catSel').parents().addClass('minusimageapply');

and now it seems to be working how I wanted it to. Thank you everyone who tried to make sense of my question and help me out.

jsFiddle: http://jsfiddle.net/nNR9W/

HTML:

<li>
<a href="foo">Catalog Section 4</a>
<ul class="level-1 catList"><li class="plusimageapply">
    <a href="foo">Quick Disconnects</a>
    <ul class="level-2 catList" style="display: none; ">
        <li id="catSel" class="selectedimage">
            <a href="foo">Foster</a></li>
        <li class="selectedimage">
            <a href="foo">General Pump</a>
        </li>
        <li class="selectedimage">
            <a href="foo">Hansen</a>
        </li>
        <li class="selectedimage">
            <a href="foo">Parker</a>
        </li>
    </ul>
    </li>
    <li class="selectedimage">
        <a href="foo">Quick Disconnects O-Rings</a>
    </li>
</ul>

​
jQuery:

$(document).ready(function() {
// Set expandable UL elements class to 'plusimageapply'
$('ul.catList li:has(ul):not(#catSel)').addClass('plusimageapply');
// Set unexpandable LI elements class to 'selectedimage'
$('ul.catList li:not(:has(ul))').addClass('selectedimage');
// Set expanded UL elements class to 'minusimageapply'
$('ul.catList li#catSel:has(ul)').addClass('minusimageapply');

// Hide expandable UL elements that are not currently selected with ID 'catSel'
$('ul.catList:not(.level-0) li:has(ul):not(#catSel)').children('ul').hide();

// **** FIXED MY PROBLEM ****
// If an elementwith its id="catSel" show all of its parents and also update the parents class
$('#catSel').parents().show();
$('#catSel').parents().removeClass('plusimageapply');
$('#catSel').parents().addClass('minusimageapply');
// **************************

// Function for expand/collapse elements
$('ul.catList:not(.level-0) li:has(ul)').each(function(column) {
    $(this).click(function(event) {
        if (this == event.target) {
            if ($(this).is('.plusimageapply')) {
                $(this).children('ul').show();
                $(this).removeClass('plusimageapply');
                $(this).addClass('minusimageapply');
            }
            else {
                $(this).children('ul').hide();
                $(this).removeClass('minusimageapply');
                $(this).addClass('plusimageapply');
            }
        }
    });
});
});​
  • 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-02T04:02:41+00:00Added an answer on June 2, 2026 at 4:02 am

    Here’s what I came up with, in an attempt to decipher your question. Hope it helps.

    EDIT: New http://jsfiddle.net/nNR9W/18/

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

Sidebar

Related Questions

I have a Product and Category entity in many-to-many association. I am trying to
I'm trying to have images fade in with css3 once they're loaded. The problem
I am trying to have a method that takes in a username and will
http://markallanson.net/wordpress/index.php/category/rsmb/ I was trying to follow the above link for setting up mqtt as
I have a browse category query that im trying to optimize. Im ending up
I have an elasticsearch index with numeric category ids like this: { id: 50958,
In codeigniter 1.73 i'm trying to display books by category. so if i have
I have a Category resource, and am trying to link to Categories#show in its
What I'm trying to do:- Index page would have a dropdown of say categories,
I am trying to use the Category described in this article: http://iphonedevelopment.blogspot.com/2008/10/shuffling-arrays.html I have

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.