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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:20:11+00:00 2026-05-14T23:20:11+00:00

I have two links & I want to show / hide them one at

  • 0

I have two links & I want to show / hide them one at a time, my code is :

<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
 <script type="text/javascript" src="js/jquery.js"></script>          
 <script type="text/javascript">                                         
   // we will add our javascript code here    
   $(document).ready(function() {
       $(function(){
           $('#link').click(function(){
           $('#colorDiv').slideToggle('slow');
            return false;
          });
        });
 });
 </script>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
 #dv {
  width:100px;
  height:100px;
  border:1px solid;
}
</style>
</head>
<body>
<table cellspacing="2">
    <tr><td><a href="#" id="link">Color</a></td><td><a href="#" id="link">Car</a></td></tr>
    <tr><td><div id="colorDiv">Red</div></td><td><div id="carDiv">PRADO</div></td></tr>
</table>
</body>
</html>

by default first div should me shown.
hanks.

  • 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-14T23:20:12+00:00Added an answer on May 14, 2026 at 11:20 pm

    Here is your code with comments.

    <!DOCTYPE html> 
    <html> 
    <head>
    <script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
    </script>
    <style>
    #carDiv {
    display: none; /* set initial carDiv visibility to hide */
    } 
    </style>
    <style>
     #dv { 
      width:100px; 
      height:100px; 
      border:1px solid; 
    } 
    </style>
     <script type="text/javascript" src="js/jquery.min.js"></script>           
     <script type="text/javascript">
    $(document).ready(function() {
      $('#link1').click(function(){ 
           $('#colorDiv').slideToggle('slow'); 
            return false; 
          }); 
     $('#link2').click(function(){ 
           $('#carDiv').slideToggle('slow'); 
            return false; 
          });     
      }) 
     </script> 
    <meta charset=utf-8 /> 
    <title>JS Bin</title> 
    <!--[if IE]> 
      <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> 
    <![endif]--> 
    </head> 
    <body> 
    <table cellspacing="2"> 
    <tr><td><a href="#" id="link1" class="link">Color</a></td><td><a href="#" id="link2" class="link">Car</a></td></tr> 
        <tr><td><div id="colorDiv">Red</div></td><td><div id="carDiv">PRADO</div></td></tr> 
    </table> 
    </body> 
    </html> 
    

    Remarks:

    First – id should be a unique identifier, so I changed ids to link1 and link2.

    Second No need to include 2 jquery libraries – use either one of them – local (src=”js/jquery.min.js”) or one from Google (src=”http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js”)

    Third If You want to use multiple selectors, like You did that with multiple id “link”, use
    class selector instead of id. Then in Jquery You select that using $(‘.link’).click….
    Google jquery selectors

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

Sidebar

Related Questions

lets say i have two pages links.html & contents.php ... first page contains only
I have two links I use for sorting. One by Make and one by
I have two links, one with id #calendar_arrival_open and another with #calendar_departure_open. Both links
I have two jquery scripts on one page that both target on-site links via
In template I have two strings which I want to combine in one. {assign
I have two links with classes (login-form and register-form) relevant to their target forms
I have the following two links in my main menu, and I have some
For technical reasons on a site we may have two or more links that
Let's say I have two tables: Category and Product , and Product links to
I have a database that which contains two tables, links and tour. Tour is

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.