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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:34:27+00:00 2026-05-20T06:34:27+00:00

First I write a pull down top menu in the html: <div class=top-menu-contain> <div

  • 0

First I write a pull down top menu in the html:

<div class="top-menu-contain">
    <div class="pull-button" ><a href="#">Show Me</a></div>
    <div class="pull-button"style="display: none;"><a href="#">Hide Me</a></div>
</div>

In default state ,the top menu at the top of the browser with “fixed” css property,and set the “top:-100px;”,only show the pull button.Then I write the jquery code to achieve a effect that make the menu slide down:

    $('.pull-button a').toggle(function () {
        $('.top-menu-contain').animate({ top: '+=100px' }, 'slow');
    }, function () {
        $('.top-menu-contain').animate({ top: '-=100px' }, 'slow');

actully this work well, then I add a funtion that,when the menu slide down,the button could change from”Show Me” to “Hide Me”,then I add this jquery code :
$(“div.pull-button”).toggle();
So the total jquery code is:

 $('.pull-button a').toggle(function () {
        $('.top-menu-contain').animate({ top: '+=100px' }, 'slow');
        $("div.pull-button").toggle();
    }, function () {
        $('.top-menu-contain').animate({ top: '-=100px' }, 'slow');
        $("div.pull-button").toggle();
    });

However it doesn’t work right now, the button could change ,it become slide down twice,then slide up twice

here is the online case

So what wrong with my jquery code ?How can I achieve it in correct way?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-05-20T06:34:28+00:00Added an answer on May 20, 2026 at 6:34 am

    The problem is that you have two as here, which you’re toggling between. What happens when you press the link is this:

    • First click: First toggle block is executed for the first anchor.
    • Second click: First toggle block is executed for the second anchor.
    • Third click: Second toggle block is executed for the first anchor.
    • Fourth click: Second toggle block is executed for the second anchor.

    You can get around this by only using one anchor, and updating the text in it instead:

    $('.pull-button a').toggle(function()
    {
        $('.top-menu-contain').animate({ top: '+=100px' }, 'slow');
        $('div.pull-button > a').text("Hide Me");
    }, function()
    {
        $('.top-menu-contain').animate({ top: '-=100px' }, 'slow');
        $('div.pull-button > a').text("Show Me");
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing HTML code for a Java servlet. I first write the code in
I'm trying to write my first iterator class / container type. Basically, I want
The following function will pull down first X messages from Twitter firehose, but looks
Have had to write my first proper multithreaded coded recently, and realised just how
I am trying to write my first real python function that does something real.
Currently I'm trying to write my first Python library and I've encountered the following
I am trying to write my first WCF project. I have created a project
I'm just about to write my first application in a duck typed language (Groovy).
I'm trying to write my first iPhone app, and I'm using a date picker
I'm using fwrite() and fread() for the first time to write some data structures

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.