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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:14:27+00:00 2026-06-09T07:14:27+00:00

I am relatively new to jQuery, and I seem to be stuck with this

  • 0

I am relatively new to jQuery, and I seem to be stuck with this mouseenter/mouseleave problem. I would like to setup a menu that “hides” when the page isn’t at the top, which seems to be working fine, when it’s hidden I would like to make it so when a user hovers over it the class switches and the menu comes back out. However, I don’t want this when it gets scrolled back to the top. It works fine when the page first loads (in firefox and chrome) and I haven’t scrolled yet, but after scrolling down and back to the top the menu will hide on mouseleave.

Here is a jsFiddle of my current code setup.

I’ve been trying to solve this for awhile now, and have tried a few other methods.

I tried just using hover like this

$("#access").hover(function() {
            $(this).removeClass("scroll").addClass("normal");
        }, function() {
            $(this).removeClass("normal").addClass("scroll");
        });

but that did the same thing as the code I have right now.

Some of the other methods I tried was to pass the b variable to another function, create a seperate div and track it’s position to determine whether or not to use the mouseenter/mouseleave, and finally to bind them, but none of this seemed to work as I thought it should.

I can’t think of anything else to try, so I am not sure if it’s something I’m doing wrong or if this isn’t even possible to accomplish like this.

This is my first question I tried to include as much information as I could think of hopefully it’s enough information.

  • 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-09T07:14:28+00:00Added an answer on June 9, 2026 at 7:14 am

    Try this

    $(document).ready(function() {
        $(window).scroll(function() {
            var b = $(window).scrollTop();
            $("#access").toggleClass("normal", b == 0)
            $("#access").toggleClass("scroll", b > 0)
        });
        $("#access").hover(function() {           
            if($(window).scrollTop() > 0){
                $("#access").toggleClass("normal scroll");
            }
        });
    });​
    

    http://jsfiddle.net/bJquD/6/

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

Sidebar

Related Questions

I'm relatively new to JQuery and would like to try something. I just followed
I am relatively new to jQuery, and I would like to be able to
Relatively new to JQuery. I've got some code that does a banner swap with
I am relatively new to Jquery and I was wondering how would one post
Relatively new to jquery. I'm trying to make a button like the accordion button...something
I'm relatively new to jQuery/Ajax and I was wondering what would be the best
I am relatively new to jQuery, I am trying to work around this code
I am relatively new to jQuery so this may be a beginners mistake, but
I'm relatively new to Jquery so please feel free to slap me if this
I am relatively new to JQuery, so please excuse this question if it seems

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.