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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:31:35+00:00 2026-06-09T19:31:35+00:00

I have got a button that only appears when it hits a certain media

  • 0

I have got a button that only appears when it hits a certain media query. Now it works fine, the button appears, clicking the button will reveal the sidenav. Clicking again closes the menu.

My problem is this – I’ve got a class that toggle with it as well, called ‘open’. This enables me to use a different icon to represent open and close. But i need a delay on the toggle class so the icon doesn’t change until the menu bar has closed.

$(document).ready(function() {
        /* prepend category button */
        $('.side-bar').before('<div id="button"><p class="sidebar-button"> Menu </p></div>'); //insert html for menu button

            $(".sidebar-button").click(function() { //click menu button and do..

                setTimeout(function(){ //i added this..

              $(".side-bar").slideToggle(); //toggle sidebar
              $(this).toggleClass("open"); // toggle class on button for 'open'
            });
        },5000); // other part of the seTimeout
    });

Whats the best way to achieve this? Live example for the purpose of this question: http://jsfiddle.net/rXt39/2/

EDIT

This might help someone looking for a similar thing. I found a solution here:

jQuery and setTimeout

Note: I ended up changing my code on the answer below. It’s now working perfectly.

  • 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-09T19:31:37+00:00Added an answer on June 9, 2026 at 7:31 pm

    Use a callback for the menu to toggleClass the icon when its finished

          $reference = $(this)
    
          $(".side-bar").slideToggle(function(){
                $reference.toggleClass("open");           
          });
    

    I added a .open class in the CSS to turn the word menu yellow while expanded.

    solution

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

Sidebar

Related Questions

I've got a gridview that renders as a table. I have an Add button
I have a home page activity that I got from an example, which works
I have an AlertDialog in and it's got a button, which, if selected, will
I have got a group of radio buttons that when clicked need to display
I have got a dropdownlist, a submit button and a textbox in my view.
I have a button in a view which refuses to work. I've got in
I've got a FORM which contains a 32*50 TEXTAREA and a Submit button. Now
I have 8 textboxes that only accept integers. How to calculate the total of
I got this code working! I have a button inside a my UserControl dropped
I have some jQuery code that highlights which radio button is checked by turning

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.