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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:03:39+00:00 2026-06-09T16:03:39+00:00

I have a div called ‘info’ that I want to be displayed when a

  • 0

I have a div called ‘info’ that I want to be displayed when a button is clicked.

<button>Toggle</button>
<div id="toggle">
Test
</div>

Basically I would like to use jQuery to reveal it with a sliding feature but I don’t know how. I can find most of the code online and see snippets, but I don’t actually know WHERE to put most of it, could someone please walk me through what and where I would need to put the relevant bits of code (from scratch) to get this working? Thank you.

  • 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-09T16:03:40+00:00Added an answer on June 9, 2026 at 4:03 pm

    CSS

    #toggle {
      display: none
    }
    

    jQuery

    $(document).ready(function() {
       $('button').on('click', function() {
         $('#toggle').slideToggle();
       });
    });
    

    A little explanation:

    • $('button') is the selector to the button tag.

    • $('button').on('click', is for bind click event to button.

    • the second parameter of on() here is callback handler and code within it will execute after click to the button.

    • $('#toggle') is the selector to the div with id=toggle.

    • $('#toggle').slideToggle() will make a sliding (up-down) effect to the div when button click.


    Note

    You should do your code within jQuery dom ready function. Which is like:

    $(document).ready(function() {
      // your code
    })
    

    in short

    $(function() {
      // your code
    });
    

    As these are JavaScript code, so you need to put them within <script> tag. for example:

    <script type="text/javascript">
        $(document).ready(function() {
           $('button').on('click', function() {
             $('#toggle').slideToggle();
           });
        });
    </script>
    

    But, if you write this code to an external file then you have to include that file within <head> tag like below:

    <script type="text/javascript" src="src_to_script"></script>
    

    According to comment

    Is it possible to make the button disappear when it is first clicked?

    Yes, possible. Try like below:

    $(document).ready(function() {
       $('button').on('click', function() {
         $(this).hide(); // disappear the button after first click
         $('#toggle').slideToggle();
       });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a div id called common, the content that I would like to
I have a div called 'main-container' that I want to be the height of
I have a div called test and mvc action in the client controller The
I have a div called 'divLinks' I want all links inside the divLinks to
So I have this div called top nav, i.e.: <div id=topnav> And I would
I have a div that contains within itself logout button and username. If the
I have a div called #top. I would like it to fade out when
I have a div called target which is centred and displayed over a google
i have div called commentbox and i want to have border solid color #ccc,
Let's say i have a div called .number containing a number. i want to

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.