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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:58:59+00:00 2026-06-18T09:58:59+00:00

I am looking to get some guidance with a simple jquery problem. I am

  • 0

I am looking to get some guidance with a simple jquery problem.

I am trying to show/hide content when I press buttons. I have 2 buttons. I want one button to show the content of 1 div and I want the other button when pressed to hide the content of the first div and show the content of 2nd div.

I created a JSFiddle here http://jsfiddle.net/Yn3tt/1/

My thinking was that I could toggle a class called noDisplay which would get set on the div I don’t want to show (thus hiding it) I am not sure of the jquery to do this?

I am also not sure if this is easier to use the jquery show/hide class to achieve this?

Thanks

My HTML is as follows

<button id="opt1">Option 1</button>
<button id="opt2">Option 2</button>

<div class="yesDisplay">
<p>Show me when I press Option 1 and hide Option 2 content</p>
</div>

<div class="noDisplay">
<p>Show me when I press Option 2 and Hide Option 1 content</p>
</div>

and my CSS is simply

.noDisplay{display:none;}

.yesDisplay{display:block;}

demo is here http://jsfiddle.net/Yn3tt/1/

  • 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-18T09:59:00+00:00Added an answer on June 18, 2026 at 9:59 am

    use hide() show() jquery function..click() event to fire when click…I made this as simple as possible so that you will easily understand

    CSS

    .noDisplay{display:none;}
    .yesDisplay{display:none;}
    

    JQUERY

     $('#opt1').click(function(){
         $('.yesDisplay').show(); //class selector for the div to show
         $('.noDisplay').hide();
     });
    
    $('#opt2').click(function(){
         $('.noDisplay').show();
       $('.yesDisplay').hide();
    });
    

    however you can use function like.. toggle() slideToggle() to reduce your code

    fiddle here

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

Sidebar

Related Questions

still a bit of a n00b on SharpSVN, I'm looking to get some simple
I'm using sorl-thumbnail to get some images to crop. I have a model looking
I have a common scenario that I am looking for some guidance from people
I have been looking for a tutorial or a some guidance as to how
I was looking for help with a problem I have using cURL to get
I am looking for some guidance. I am trying to select the following From
I'm new to IOS, and was looking for some guidance. I have a long
I'm looking to make a website that will probably get some heavy, repetitive traffic.
I'm looking to parse some CXML in PHP...basically all I'm looking to get the
I'm looking for some guidance here. On my site I put things in Web

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.