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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:47:38+00:00 2026-05-25T00:47:38+00:00

I was searching for a pure CSS answer to hiding and showing content but

  • 0

I was searching for a pure CSS answer to hiding and showing content but after no luck I have been playing around with a piece of JavaScript code. My question is below the code, as it may help you to see the code first.

      <script type="text/javascript">
    $(document).ready(function(){
            $('.text_container').addClass("visible");

        $('.text_container').click(function() {
            var $this = $(this);
            if ($this.hasClass("visible")) {
                    $(this).removeClass("visible").addClass("hidden");
            } else {
                    $(this).removeClass("hidden").addClass("visible");
            }
        });
    });
   </script>  


        <div id="services" class="text_container"> 
         <h4>SERVICES</h4>
             <div>
              <p>Loads of text blah blah blah</p>
             </div>
         </div>


         /* HIDE and SHOW content JavaScript function */
  .hidden div {display:none;}
  .visible div {display:block;} 

  .text_container {
      background-color: #39b54a;
     background-image: url("pattern2.png");
     border: 1px solid #777777;
    box-shadow: 0 1px 1px  inset, 0 0 40px rgba(0, 0, 0, 0.5) inset, 0 16px 0 rgba(255, 255, 255, 0.4) inset, 0 4px 5px rgba(0, 0, 0, 0.6);
    color: #000000;
    padding: 5px;
    text-align: left;
    width: auto;

  }
  .text_container h4 {
     cursor: pointer;
  }
  .text_container div p {
      margin-bottom: 10px;
  }
  .visible > div {
   display: block;
   font-size: 17px;
    height: 100%;
  }

  #rating > div {
    clear: left;
    height: 260px;
  }
  /* end of HIDE and SHOW content javascript function */  

Currently as expected the div with class = text_container area is clickable, so if a place a form in the child DIV when you select the form the content hides. I Would like to make only the H4 element
clickable so clicking on the shown content will not hide the content.

I am useless at JavaScript and I imagine this requires rejigging the js.

  • 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-25T00:47:38+00:00Added an answer on May 25, 2026 at 12:47 am

    You can use:

    $('.text_container h4').click(function() {
        if($(this).hasClass("visible")) {
            $(this).removeClass("visible").addClass("hidden");
        } else {
            $(this).removeClass("hidden").addClass("visible");
        }
    });
    

    The content in the $(‘ … ‘) is just like a CSS selector, so if you know CSS then it won’t be a problem for you.

    With CSS you could style that h4 element with:

    .text_container h4 { color: #000000; }
    

    and just the same, you can create a wrapped set with jQuery that selects it with:

    $('.text_container h4')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been searching for a pure Java SSH library to use for a
I have been searching for about a week now and found such pure AS3
I've been searching a lot for a clear answer or explanation, but can't find
Searching for a while now, but haven't found a suitable answer to my problem.
I have been searching for more than 1 hour with no success. Is there
I have been searching for a way to skin C# applications under Windows Forms.
Searching turns up a simple definition: data hiding. But, consider the following two examples:
Searching here I found that this question was already asked , but I think
Searching online, I have found the following routine for calculating the sign of a
searching around trying to find a way to add index on suffix of a

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.