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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:07:15+00:00 2026-05-26T23:07:15+00:00

I have a jsfiddle below: http://jsfiddle.net/Jsh2V/10/ The first sets of test buttons (show it

  • 0

I have a jsfiddle below:

http://jsfiddle.net/Jsh2V/10/

The first sets of test buttons (“show it” and “hide it”) work great. I have been trying to get the second set of buttons (“Have it” and “Need it”) to do the same thing with a div. Not working. Any suggestions? Also, if theres a more efficient way to do this…

Here the code from the Fiddle:

<!DOCTYPE html>
<html>
<head>
  <style>
      p { background:yellow; }
      </style>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
  <button class="1">Show it</button>
  <button class="2">Hide it</button>

      <p style="display: none" class="1">Hello</p>
      <p style="display: none" class="2">Un Hello!</p>
<script>
    $("button.1").click(function () {
    $("p.1").show("slow");
    $("p.2").hide("fast");
    });
</script>
<script>
    $("button.2").click(function () {
    $("p.1").hide("fast");
    $("p.2").show("slow");
    });
</script>


    <button class="have">Have</button>
    <button class="need">Need</button>

    <div id="have" style="display: none">HAVE YO</div>
    <div id="need" style="display: none">NEED YO</div>
<script>
    $("button.have").click(function () {
    $("div.have").show("slow");
    $("div.need").hide("fast");
    });
</script>
<script>
    $("button.need").click(function () {
    $("div.need").show("slow");
    $("div.have").hide("fast");
    });
</script>
</body>
</html>
  • 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-26T23:07:16+00:00Added an answer on May 26, 2026 at 11:07 pm

    Should be div#have instead of div.have, since your divs have an id of have, not a class of have.

    <script>
        $("button.have").click(function () {
        $("div#have").show("slow");
        $("div#need").hide("fast");
        });
    </script>
    <script>
        $("button.need").click(function () {
        $("div#need").show("slow");
        $("div#have").hide("fast");
        });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the jQuery below http://jsfiddle.net/XMdYw/7/ var elements = ''; var ELEMENT_COUNT_PER_PAGE = 301;
I have a jsFiddle that I am working with: http://jsfiddle.net/aL7Xe/77/ It all works great,
http://jsfiddle.net/MwQbE/ i have the jQuery Below but i cant get the variables to pass
Here's the JSFiddle (disregard the differences with picture below): http://jsfiddle.net/stapiagutierrez/y2PhX/ I'm supposed to have
This is easier to show than explain: http://jsfiddle.net/gN4VZ/ Is it possible to have my
I have: http://jsfiddle.net/Gkz4v/9/ .pagination li a { float: left; width: 6px; height: 6px; line-height:
I have a jsfiddle here : http://jsfiddle.net/hhimanshu/eLhLS/1/ Current: On keypress, it keeps on appending
I have a jsfiddle http://jsfiddle.net/4Pc4B/10/ . In the jsfiddle, type in a question in
I have a jsfiddle here: http://jsfiddle.net/ybZvv/22/ The situation I have is that if you
i have done this http://jsfiddle.net/thilakar/WsxJy/3/ using with anchor tag and name attributes. but i

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.