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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:08:34+00:00 2026-06-15T08:08:34+00:00

I have a main nav button that moves down slightly On hover, then back

  • 0

I have a main nav button that moves down slightly On hover, then back again on hover out. On click of this button releases a dropdown div that contains lots of html, on click again and obviously the box goes back up. However other buttons with dropdowns on the page and they need to get out of each others way, so each button also closes every other dropdown box as well. Right now im doing it with toggle which, if you close the box with another button, you have to click twice to get the dropdown down again on the main button.

Toggle is efficient, but what would be the efficient way to do toggle style jquery animations with if statements? so something like on click if animated down, animate up else animate down. I basically dont know how to write inside the if part. I have seen examples with something like if(:animated) but thats to tell if there was any general animation.I have lots of instances I want to apply this to so I need to be specific like:

if(:animation).top = 150{ (div).animate(top = 0)} else {(div).animate(top = 150)}

also, when you rollover and the top button moves down a bit, how would I keep it down when the dropdown is down and goes back up when the dropdown goes back up?

here is a jsfiddle so you can see what im talking about easier. Its not perfect but my homepage looks similar, let me know if I was confusing on any part and I will edit this!

http://jsfiddle.net/9DN52/1/

  • 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-15T08:08:35+00:00Added an answer on June 15, 2026 at 8:08 am

    In my opinion your code is efficent enough so what you need to do just add a class to see if its clicked than stop hover’s action with it.

    jQuery:

    $("#down").hover(
        function() {
            $(this).stop().animate({top:0},200);
        },
        function() {
            // this will alert the situation for you to understand
            alert($(this).hasClass("isDown"));
            // if its clicked than do not move!
            if ($(this).hasClass("isDown") == false) {
                $(this).stop().animate({top:-5},220);
            }
        }
    );
    
    $("#down").click(
        function() {
            $("#DropUp").stop().animate({bottom:-250},220);
            // Add a class to see if its clicked
            $(this).toggleClass("isDown");
        }
    );
    

    worked around your fiddle: http://jsfiddle.net/9DN52/14/

    Edit:

    I also solved a couple bugs, made some code fixes, added descriptions and i thought what you actually wanted to do was this:

    jQuery:

    // Actually you can do this with css transition
    // Remove these descriptions for a cleaner looking code
    $("#down").hover(
        function() { $(this).stop().animate({top:0},200); },
        function() {
            // if its clicked than do not move!
            if ($(this).hasClass("isDown") == false) {
                $(this).stop().animate({top:-5},220);
            }
        }
    );
    // Instead of toggle simple click action is enough
    $("#down").click( function() {
        // Thanks to class selector now we know
        // if its clicked or down, so we know what to do..
        if ($("#down").hasClass("isDown") == false) {
            $("#DropDown").stop().animate({top:0},250);
            // if footer is up already this will hide it
            $("#DropUp").stop().animate({bottom:-250},220);
            $("#up").removeClass("isUp");
        } else {
            $("#DropDown").stop().animate({top:-250},220);
        }
        // Each click should change the down situation
        $("#down").toggleClass("isDown");
    });
    // Instead of toggle simple click action is enough
    $("#up").click( function() {
        // If its up already
        if ($(this).hasClass("isUp") == false) {
            $("#DropUp").stop().animate({bottom:0},250);
            // if header is down already this will hide it
            $("#DropDown").stop().animate({top:-250},220);
            $("#down").stop().animate({top:-5},220).removeClass("isDown");
        } else {
            $("#DropUp").stop().animate({bottom:-250},220);
        }
        // Each click should change the up situation
        $("#up").toggleClass("isUp");
    });
    

    fiddle: http://jsfiddle.net/9DN52/43/

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

Sidebar

Related Questions

I have the below site: http://kelseydelo.com/ When I click the main nav links in
I have a nav bar with a drop down that is working beautifully. The
So I have this menu and when I click on a button I need
So, I have a main menu, and when I click one button from the
I have a hover mousein mouseout setup as follows for a list item: $(#main-nav
My intention is to have 4 main Nav-bars at a site. If the user
I have a nav bar with children unordered lists nested under the main navbar
I have main window which has inner grid components. When I press a button
I have main table called 'Employee' and another slave table called 'EmployeeTypes' that has
Splash I have main activity UI startup operations that take between 5-10 seconds (that

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.