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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:18:24+00:00 2026-05-25T13:18:24+00:00

I have a case where I need to toggle the visibility of an element

  • 0

I have a case where I need to toggle the visibility of an element based on whether a particular operation (categorization) is in progress if so, it’s hidden, else it’s visible.

Now I have css which looks like this:

.isCategorizing .category.all {
   display:none;
}

i.e., it means that that div with class(es) .category.all should be hidden if it’s parent(s) have the class .isCategorizing

Now in jquery if I toggle the visibility of the .category.all element an inline style is added to the HTML taking precedence over the CSS in the .css file!! So even if the above is true the visibility value from the inline style seems to take precedence and the element is NOT hidden. On being visible jquery add’s style=display:list-item; to the div whereas my CSS should make it hidden…

I could handle this in pure jQuery but there are too many states and checks to make sure that it should work in that particular manner as well as maintain a boolean flag to “remember” if that state existed and whether to revert to that state ever. The CSS approach is simpler and much cleaner, but the inline style is the irritating bit…

…how best to deal with this? I tried creating another class .hide and toggled that with jquery. Seems to work but for some reason screws up the positioning of my element. I’m playing with it but can’t seem to find a clean solution to this problem. Any advice??

Update:

Here is the corresponding CSS:

.category{
        position:relative;
        padding:1px;
        margin:2px 0 5px 0;
        clear:both;
        font-family:arial, sans-serif;
        font-size: 14px;
        display:inline-block;
        width:inherit;
    }   


.category.all {
        display:none;
        width:200px;
        text-align: center;
        padding:3px;
        border:2px solid transparent;
        border-radius: 4px;
        background-color: #DDDFE3;
    }

NOTE: A simple toggleClass doesn’t work in this case – toggling “all” would cause the button to be visible even when it shouldn’t be. Second, I’m inheriting a few props from the .category class since this button is displayed at the end of the ‘category list’ so to speak and wanted to prevent duplication.

If I go with toggleClass and just duplicate the props it may work, on second thought…lemme try this and post an update

  • 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-25T13:18:25+00:00Added an answer on May 25, 2026 at 1:18 pm

    After all the clarifications it seems that:

    • If the button has .all, you want it to be hidden (irrespective of whether the parent has .isCategorizing)
    • If the button does not have .all, you want it to be hidden if and only if the parent has isCategorizing

    If this is the case, the simplest is to reverse the meaning of the all class and use a class partial in its place. You can then do:

    .category {
        display: none;
    }
    
    .category.partial {
        display: inline-block;
    }
    
    .isCategorizing .category.partial {
        display: none;
    }
    

    If scrapping .all would introduce problems in other code you do not show here, you can keep using it and also introduce .partial (in which case I would prefer it be named .not-all so that the relation is more apparent to maintainers). You can do this by:

    1. Adding toggleClass('.not-all') to the one or two places where you already have toggleClass('.all'), and
    2. Moving the display CSS style setters inside new selectors which will be triggered by the new not-all class
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a case where I need to update a jqgrid based on some
I have a case where I need to show only the top rows based
I have a case where I need to select a random item, but I
I have a case where I need to load bitmap from a resource dll
I have a use case where I need to call a (non-static) method in
I have a very specific case that I need to debug. I need to
I have a use case where I only need to store certain fields to
I have a complicated problem, and I need help. I have a base case,
I have a strong use case for pre-allocating all the memory I need upfront
I have a case where i need to add the Javascript from controller 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.