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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:09:24+00:00 2026-06-13T01:09:24+00:00

I have some jquery which reveals and hides new div’s based on which button

  • 0

I have some jquery which reveals and hides new div’s based on which button is pressed. Rather than buttons i would like to insert my own text/image and have them work in the same way, revealing and hiding the new windows.

Here is the jquery:

<script>
    $(document).ready(function(){

        $(".buttons").click(function () {
        var divname= this.value;
          $("#"+divname).show("slow").siblings().hide("slow");
        });

      });
</script> 

Here is the code for one of the buttons which i would like changed to a a href tag.

<input type="button" id="button1" class="buttons" value="div1"></input>

Any help will be greatly appreciated. Thanks. Pia

  • 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-13T01:09:26+00:00Added an answer on June 13, 2026 at 1:09 am

    You can use the jQuery data() method – http://api.jquery.com/data/ – to store arbitrary data on the anchor element (the div ID) and then use that value to show the proper div:

    <div id="div1">div one</div>
    <div id="div2">div two</div>
    <a href="#" class="abuttons" data-divid="div1">link</a>
    
    <script>
    $(document).ready(function(){
        $(".abuttons").click(function () {
            var idname= $(this).data('divid');
            $("#"+idname).show("slow").siblings().hide("slow");
        });
    });
    </script>
    

    If you want to show two div’s using a class name instead of an ID, store the class name on the achor tag, set the same class on each of the divs you want to show, and reference it in jQuery using a . instead of a #

    <div id="div1" class="divclass">div one</div>
    <div id="div2" class="divclass">div two</div>
    
    <a href="#" class="abuttons" data-divclass="divclass">link</a>
    
    <script>
    $(document).ready(function(){
        $(".abuttons").click(function () {
            var classname= $(this).data('divclass');
            $("."+classname).show("slow").siblings().hide("slow");
        });
    });
    </script> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following psudeo html. I need to write some jquery which hides
I have some jQuery code that highlights which radio button is checked by turning
I have some jQuery functions which update some numbers when new values are selected
I have written some jquery code to select the div which is grandchild of
I have some questions regarding js file based on Jquery : 1) Which algorithm
I have some jquery which will calculate the items in my menu and assign
I have some jquery code which I am trying to translate to YUI. I
I have some tabs using jQuery UI which work just fine, but I want
I have some jQuery code, which attempts to show the first 6 divs on
I have some onchange events setup in jQuery which are used to populate 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.