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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:58:28+00:00 2026-05-23T15:58:28+00:00

I am an absolute beginner in this field. I have written the following code

  • 0

I am an absolute beginner in this field. I have written the following code but it’s not working. Can someone explain where is the error?

<script type="text/javascript">
    $("button").click(function(){
        $("div").show("slow");
    });
</script>

<button>show</button>
<div style="min-height:300px; min-width:400px; border:10px solid grey; display:none;"></div>
<a href="http://#" style="display: none">this is a link</a>
  • 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-23T15:58:28+00:00Added an answer on May 23, 2026 at 3:58 pm

    You execute the jQuery before the button is there. So at the point jQuery is executed, the button is not existent.

    The solution is to use $(document).ready(...).

    All elements on a page (HTML) are parsed to the DOM of that page. The DOM is a hierarchical collection of all elements. You can select elements out of it using jQuery.

    However, obviously the DOM needs to be fully there before you can select the elements. In your case, you first select the button, and create it afterwards. That does not work. At the time of the selector the button does not exist yet.

    Using jQuery’s $(document).ready(), you can defer the function containing selectors until the DOM is fully loaded and parsed – at which time the selector works because the elements are there.

     <script type="text/javascript">
    $(document).ready(function() {
    
            $("button").click(function(){
                $("div").show("slow");
            });
    
    });
            </script>
    
            <button>show</button>
            <div style= "min-height:300px; min-width:400px; border:10px solid grey; display:none;"></div>
             <a href="http://#" style="display: none">this is a link</a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Absolute beginner question: I have a template file index.html that looks like this: ...
This is an absolute beginner's question, but per the latest podcast, I understand that
I'm an absolute beginner, you see. Say I have a string object on the
I'm just playing with some linq and asp.net - absolute beginner so I'm not
This is an absolute beginner question in TFS SDK: I am trying to connect
I'm an absolute beginner with ASP.NET[MVC] so this is probably a dumb question. I
Ok, I am an absolute beginner in powerbuilder. Currently I am working in a
Working through Jerry Lee Ford Jr.'s Powershell 2.0 for the Absolute Beginner book. There's
Spoiler: I am an absolute beginner to C. I quickly threw threw together this
I am absolute beginner in C#, ASP.NET and MVC2 and this means that 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.