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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:02:56+00:00 2026-06-04T07:02:56+00:00

I know this would involve Jquery, I am not as learned as I’d like

  • 0

I know this would involve Jquery, I am not as learned as I’d like to be in mocking this up myself. I know there is a toggle function, but dont know how I’d mock this up for my own use.

This might be possible in css3 too? But Im guessing Jquery would be a better cross browser solution.

  • 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-04T07:02:57+00:00Added an answer on June 4, 2026 at 7:02 am

    Assuming you have a button, or other element, with a specific id:

    $('#id').click(
        function(){
            $('.className').toggle();
        });
    

    Or, to be a little prettier:

    $('#id').click(
        function(){
            $('.className').fadeToggle();
            /* or:
            $('.className').slideToggle();
            */
        });
    

    This is, given some fairly specific mark-up constraints and low cross-browser compatibility requirements, possible in CSS, albeit only in CSS3:

    HTML:

    ​<a href="#show">Show all</a>
        <div id="show">
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <a href="#">hide</a>
    </div>​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​
    

    CSS:

    div {
        height: 0;
    }
    div > a {
        opacity: 0;
    }
    div:target a {
        opacity: 1;
    }
    
    div > ​div {
        height: 0;
        width: 0;
        margin: 0 auto;
        border-width: 0;
        border-style: solid;
        border-color: #000;
        border-radius: 1em 0;
        -webkit-transition: all 1s linear;
        -moz-transition: all 1s linear;
        -ms-transition: all 1s linear;
        -o-transition: all 1s linear;
        transition: all 1s linear;
    }
    
    div:target > div​ {
        height: 200px;
        width: 200px;
        border-width: 2px;
        -webkit-transition: all 1s linear;
        -moz-transition: all 1s linear;
        -ms-transition: all 1s linear;
        -o-transition: all 1s linear;
        transition: all 1s linear;
    }​
    

    JS Fiddle demo.

    The above can be adapted to apply, of course, to specific classes rather than all div elements, and this is one (though perhaps not the only) way to work with specific classes, using the general sibling combinator ~:

    HTML:

    <a href="#show">Show all</a>
    <a href="#firstOne">Show all '.one' elements</a>
    <a href="#firstTwo">Show all '.two' elements</a>
    <div id="show">
        <div></div>
        <div id="firstOne" class="one"></div>
        <div id="firstTwo" class="two"></div>
        <div></div>
        <div class="one"></div>
        <div></div>
        <div class="two"></div>
        <div class="one"></div>
        <a href="#">hide</a>
    </div>​
    

    CSS:

    div {
        height: 0;
    }
    div > a {
        opacity: 0;
    }
    div:target a {
        opacity: 1;
    }
    
    div > div {
        height: 0;
        width: 0;
        margin: 0 auto;
        border-width: 0;
        border-style: solid;
        border-color: #000;
        border-radius: 1em 0;
        -webkit-transition: all 1s linear;
        -moz-transition: all 1s linear;
        -ms-transition: all 1s linear;
        -o-transition: all 1s linear;
        transition: all 1s linear;
    }
    
    div:target > div {
        height: 200px;
        width: 200px;
        border-width: 2px;
        background-color: #ccc;
        -webkit-transition: all 1s linear;
        -moz-transition: all 1s linear;
        -ms-transition: all 1s linear;
        -o-transition: all 1s linear;
        transition: all 1s linear;
    }
    
    div:target > .one,
    .one {
        background-color: #ffa;
    }
    
    div:target > .two,
    .two {
        background-color: #f90;
    }
    
    .one:target,
    .one:target ~ .one {
        height: 200px;
        width: 200px;
        border-width: 2px;
        -webkit-transition: all 1s linear;
        -moz-transition: all 1s linear;
        -ms-transition: all 1s linear;
        -o-transition: all 1s linear;
        transition: all 1s linear;
    }
    
    .two:target,
    .two:target ~ .two {
        height: 200px;
        width: 200px;
        border-width: 2px;
        -webkit-transition: all 1s linear;
        -moz-transition: all 1s linear;
        -ms-transition: all 1s linear;
        -o-transition: all 1s linear;
        transition: all 1s linear;
    }
    

    JS Fiddle demo.

    Bear in mind, though, that CSS selection can only select elements that appear later in the DOM, so to show all the div elements of class="one" the target for the link has to be the first element of that class, so, to be concise, the target has to be, literally, the #firstOne. Hence the name, really, but it seemed worth specifying that.

    References:

    • fadeToggle().
    • General Sibling combinators, and :target pseudo-class, at the W3.
    • slideToggle().
    • toggle().
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this isn't a programming question but I would really like the users
I know this is stupid, but how would I do this? I would like
I know this is a weird question to ask, but I would like to
I know this is probably a very simple question but how would I do
I would like to animate things in 3D space. I know this is possible
Ok guys, I know this is pretty a rare case but I really would
I would like to know whether this is actually possible in Android? When Android
I would like to know how this homepage from Google Docs app is build
How would I compact this jQuery drop down menu code? I know you can
I don't know if this would be coined as wrong place to ask this

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.