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

  • Home
  • SEARCH
  • 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 8500325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:54:51+00:00 2026-06-11T00:54:51+00:00

I can show a table with a link label with following codes with jquery.

  • 0

I can show a table with a link label with following codes with jquery.

 $(document).ready(function()
{
    $("#show").click(function()
    {
        $("#table").show();
    });
});

but when i want to do this for a button it will show the table for a second then it will be hidden. these are the codes for the button :

$(document).ready(function()
{
    $("#button").click(function()
    {
        $("#table").show();
    });
});

Update :

    $(document).ready(function()
{
    $("#table").hide();
    $("#button").click(function()
    {
        $("#table").show();
    });

});

Here are the codes :

    <script type="text/javascript" src="jquery-1.8.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
    $("#table").hide();
    $("#button").click(function()
    {
        $("#table").show();
    });

});
</script>
</head>

<body>
<p><a href="#" id="show">Show</a> <a href="#" id="hide">Hide</a></p>
<form id="form1" name="form1" method="post" action="">
  <p>
    <input type="submit" name="button" id="button" value="Show" />
  </p>
  <p>&nbsp; </p>
</form>
<table width="515" border="0" class="table1" id="table">
  <tr>
    <td width="509" class="table1"><img src="Image/Tulips.jpg" width="400" height="400" alt="Tulips" /></td>
  </tr>
</table>
  • 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-11T00:54:53+00:00Added an answer on June 11, 2026 at 12:54 am

    Your code works just fine, maybe what you ment is a toggle here you go: Demo

    I just changed .show() into .toggle()

    $(document).ready(function()
    {
        $("#button").click(function()
        {
            $("#table").toggle();
        });
    });
    

    UPDATE:
    The problam is that you using type="submit" on your button which causes the form to get submitted… change it to type="button"

    Another way (that keeps the type="submit" there):

    $(document).ready(function()
    {
        $("#table").hide();
        $("#button").click(function()
        {
            $("#table").show();
            return false;           
        });
    
    });
    

    I added return false; to prevent the button default action.

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

Sidebar

Related Questions

I want to show a listbox(Table) with nearly 20 Million rows. How can I
I need to invoke a function on click of a link in a table
In jquery, how can I show a link that is generated on the fly
I am implementing jQuery's tablesorter, but the arrows can't seem to show. Here is
how i can to show webpage in iframe when click a link? :-? with
Can I fire show create table query in Java code for mysql? What I
How can i show and hide table rows based on value selected in multiselect?
My question is, why I can not use hide() & show() to hide/show table
if so can show simple example, ex in jquery ajax.post
I can't figure out why this background image does not show up. It seems

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.