1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

how to have on mouse hover have login box drop down

Discussion in 'jQuery' started by robby1995, Dec 25, 2013.

  1. #1
    i am building a website and i want the login box drop down when someone hovers over the word login and if the mouse goes past it the box will disappear again, any links that will help or some code that does this will be appreciated.
    robby1995, Dec 25, 2013 IP
  2. HuggyStudios

    HuggyStudios Well-Known Member

    Likes Received:
    Best Answers:
    Trophy Points:
    You can accomplish this with CSS and JavaScript pretty easily.

    Set the login box to display:none in your CSS. Then in your JavaScript file add this code. Make sure you change the ID's to match yours.

    $(function() {
      // show the login box when the user's mouse hovers over the login link
       $('#login-link-id-here').hover(function() {
      // hide the login box when the user's mouse leaves it
       $('#login-box-id-here').mouseout(function() {
    Code (markup):
    I haven't tested this as I don't have enough time. That should be enough to get you started.

    HuggyStudios, Dec 26, 2013 IP
  3. deathshadow

    deathshadow Acclaimed Member

    Likes Received:
    Best Answers:
    Trophy Points:
    Meanwhile if your only trigger is hover, I'm wondering what the devil you are even looking at javascript for -- but again most of what people say "use jQuery" for the correct answer is "NOTHING".

    <form id="hoverLogin" action="login.php">
    	<div><a href="#hoverLogin">Login</a></div>
    		<label for="hoverLoginName">User Name:</label>
    		<input type="text" name="username" id="hoverLoginName" />
    		<br />
    		<label for="hoverLoginPass">Password:</label>
    		<input type="text" name="password" id="hoverLoginPass" />
    		<br />
    		<input type="submit" value="Login" />
    Code (markup):
    The DIV is lip-service for valid code since only block-level elements can be children of FORM. The anchor and it's target are so we can make it if you click on "login" the dropdown will stay open on CSS3 browsers using :target

    #hoverLogin {
    #hoverLogin fieldset {
    #hoverLogin:target {
    Code (markup):
    We just APO the fieldset and then hide it with overflow:hidden. On :hover and :target make it overflow:visible. Simple... and no steenking javascript (or worse jQuery) for NOTHING needed.
    deathshadow, Dec 30, 2013 IP
    ryan_uk likes this.