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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:52:42+00:00 2026-05-29T10:52:42+00:00

really new to JQuery.. like 2 hours new. Began to write a drop down

  • 0

really new to JQuery.. like 2 hours new. Began to write a drop down menu for a login box like this:
HTML:

<button id="loginButton">Login</button> 

When you hover over that, this JQuery runs:

$('#loginButton').live('hover', function() {
    login_drop();   
});

function login_drop(){
$('#loginBox').fadeIn();

}

$('#loginButton').live('hover', function() {
    login_away();

});

function login_away(){
$('#loginBox').fadeOut();
}

And then this HTML DIV appears directly under the button:

<div id="loginBox">                
<label for="email_B">Email Address</label>
<input type="text" name="email_B" id="email_B" />
<label for="password">Password</label>
<input type="password_B" name="password_B" id="password_B" />
<input type="submit" id="login" value="Sign in" />
<label for="checkbox"><input type="checkbox" id="checkbox" />Remember me</label>
<span><a href="#">Forgot your password?</a></span>
</div>

and the CSS on that DIV is this:

#loginBox {
    position:absolute;
    top:70px;
    right:100px;
    display:none;
 z-index:1;
}

This all works, but the behavior of it stinks. How do I make it so you can hover over the button put your mouse in the newly appeared DIV and the div won’t fade away until your mouse leaves the div?

Sorry if my coding stinks.
Thanks a bunch guys!

——————————–EDITS AKA the ANSWERS——————–
So for all of you reading this down the line. There are so many ways of making this work depending on how you want the user to interact with it.

Here is way 1…This way the login box fades out when your mouse leaves the login button. This is a quick way fo making it work. This answer is thanks to elclanrs besure to Up 1 his answer below if you like this.

JQuery:

$(function(){
$('#loginButton').mouseenter(function(){ $('#loginBox').fadeIn(); }); 
$('#login').mouseout(function(){ $('#loginBox').fadeOut(); }); 
});

HTML:

<div id="loginBox">                
<label for="email_B">Email Address</label>
<input type="text" name="email_B" id="email_B" />
<label for="password">Password</label>
<input type="password_B" name="password_B" id="password_B" />
<input type="submit" id="login" value="Sign in" />
<label for="checkbox"><input type="checkbox" id="checkbox" />Remember me</label>
<span><a href="#">Forgot your password?</a></span>
</div>

CSS:

#loginBox {
position:absolute;
top:70px;
right:100px;
width:200px;
height:200px;
display:none;
z-index:99;
background:url(../images/162.png);
}

WAY 2 is adding is a cancel button like Jared Farrish did here:
http://jsfiddle.net/j4Sj5/4/
if you like his answer, be sure to vot him up below!!

and WAY 3 is what I’m attempting now and should be the most user friendly and flashy. I’ll post back once I get it to work correctly!

  • 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-29T10:52:43+00:00Added an answer on May 29, 2026 at 10:52 am

    EDIT

    (Subsequent EDIT: added a timeout to hide after only a mouseover on the show login element, plus some other updates.)

    While I still think using mouseenter and mouseout to handle a login form is not the right way to go from a usability perspective, below is code that demonstrates what Jim Jeffers is describing and attempts to handle some of the pitfalls of the approach:

    var setuplogindisplay = function(){
        var $loginbox = $('#loginBox'),
            $loginshow = $('#loginShow'),
            $logincontainer = $('#loginContainer'),
            $cancellogin = $('#cancelLogin'),
            keeptimeout,
            closetimeout;
    
        var keepDisplay = function(){
            clearAllTimeouts();
            keeptimeout = setTimeout(loginHide, 2000);
        };
    
        var loginDisplay = function(){
            clearAllTimeouts();
            if ($loginbox.is(':hidden')) {
                $loginbox.fadeIn();
            }
        };
    
        var loginHide = function(){
            clearAllTimeouts();
            if ($loginbox.is(':visible')) {
                if (!$(this).is('#cancelLogin')) {
                    closetimeout = setTimeout(function(){
                        $loginbox.fadeOut();
                    }, 1500);
                } else {
                    $loginbox.fadeOut();
                }
            }
        };
    
        function clearAllTimeouts() {
            if (keeptimeout) {
                clearTimeout(keeptimeout);
            }
            if (closetimeout) {
                clearTimeout(closetimeout);
            }
        }
    
        $loginshow.mouseover(loginDisplay);
        $loginshow.mouseout(keepDisplay);
        $logincontainer
            .mouseout(loginHide)
            .children()
                .mouseover(loginDisplay)
                .mouseout(keepDisplay);
        $cancellogin.click(loginHide);
    };
    
    $(document).ready(setuplogindisplay);
    

    http://jsfiddle.net/j4Sj5/19/

    Note, you have to make concessions to handle the fact mouseouts will fire when you mouse over elements within the #logincontrol element. I handle this by having them loginDisplay() on mouseenter event (it will work on mouseout, but it makes more logical sense on mouseenter).


    I would keep in mind usability of the form when trying to access it and try not to get too clever or over-engineer the user experience. Consider:

    <input type="button" id="cancelLogin" value="Cancel" />
    

    Use this to close/hide the form, not an action on another element. If you put the close form action on an event like mouseout, you’re going to aggravate your users when they move the mouse accidentally or intentionally out of the way, only to find the login form was closed when they did so. The form, IMO, should have the control which fires the event to hide it according to the user’s choice.

    <span id="loginButton">Show Login</span>
    <div id="loginBox">                
        <label for="email_B">Email Address</label>
        <input type="text" name="email_B" id="email_B" />
        <label for="password">Password</label>
        <input type="password_B" name="password_B" id="password_B" />
        <input type="submit" id="login" value="Sign in" />
        <input type="button" id="cancelLogin" value="Cancel" />
        <label for="checkbox"><input type="checkbox" id="checkbox" />Remember me</label>
        <span><a href="#">Forgot your password?</a></span>
    </div>
    
    $(document).ready(function(){
        var $loginbox = $('#loginBox'),
            $button = $('#loginButton'),
            $cancellogin = $('#cancelLogin');
    
        var loginDisplay = function(){
            $loginbox.fadeIn();
        };
    
        var loginHide = function(){
            $loginbox.fadeOut();
        };
    
        $button.click(loginDisplay);
        $cancellogin.click(loginHide);
    });
    

    http://jsfiddle.net/j4Sj5/4/

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

Sidebar

Related Questions

I'm new to jQuery and really liking it. I'd like to know if there's
im really new to linq-to-SQL so this may sound like a really dumb question,
So I tried creating the slide up down effect like in this example, http://paulsturgess.co.uk/articles/show/83-jquery-text-slide-up-slide-down-effect
I'm really new at this jquery stuff. I have a wcf web service running
I'm new to jquery and trying to accomplish something. My HTML looks like: <li>
I'm new into JavaScript and I really like jQuery and hate when it comes
I'm really new to HTML, but I can't find anywhere how to return the
I'm really new to VSTO so sorry if this is a newbie question. I'm
I'm very new to jQuery, Ajax and things like these. I've found solutions on
Simple question really, I am relatively new to both jQuery and XML. I just

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.