jquery - how to fix this weird behaviours? Hover link -> fadeIn the div, mouleave -> fadeOut the div -
trying make form appear login when mouseover on link log in class="classb" , , box information when hover on link info class="classa" , box should fadeout when mouse leaves box , link. effect weird, it's not working properly. code below, , see here: http://jsfiddle.net/75hyl/11/
<ul class="links"> <li class="classa"><a><span>my info</span></a></li> <li class="classb"><a><span>log in</span></a></li> </ul> <div id="userinfo">content goes here. box should stay visible when mouse on it, fadeout when mouse leaves</div> <div id="login" > <div class="form"> <form> login form here. box should stay visible when mouse on it, fadeout when mouse leaves </form> </div> </div> <style> .links li { display:inline-block;cursor:pointer; } .links li { padding:0 4px 0 1px; } .links li.classa {width:147px; height:77px;background:url(../images/sprites01.png) no-repeat -226px 0px;} .links li.classb {width:147px; height:77px;background:url(../images/sprites01.png) no-repeat -226px 0px;} .links li.classa span {} .links li.classb span {} .links li.classa:hover {background:url(../images/sprites01.png) no-repeat -226px -80px;} .links li.classb:hover {background:url(../images/sprites01.png) no-repeat -226px -80px;} .links li.classa {color:#fff;text-transform:uppercase;background:#00aaff;padding:5px 5px 0 20px;margin:5px 0 0;font-size:1em;height:50px;display:block;} .links li.classb {color:#00aaff;text-transform:uppercase;background:orange;padding:5px 5px 0 20px;margin:5px 0 0;font-size:1em;height:50px;display:block;} #login {display:none;width:250px;height:250px; background:#bbb;color:#000;border:1px solid red;} #userinfo{display:none;width:250px;height:250px; background:#bbb;color:#000;border:1px solid red;} </style> <script> $("li.classa").hover(function() { $("#userinfo").fadein('fast').css('display', 'block'); }); $("#login, .classa").mouseleave(function() { $("#userinfo").fadeout('fast').css('display', 'none'); }); $("li.classb").hover(function() { $("#login").fadein('fast').css('display', 'block'); }); $("#login, .classa").mouseleave(function() { $("#login").fadeout('fast').css('display', 'none'); }); </script>
$("li.classa").hover(function() { $("#userinfo").fadein('fast').css('display', 'block'); }, function() { $("#userinfo").fadeout('fast').css('display', 'none'); }); $("li.classb").hover(function() { $("#login").fadein('fast').css('display', 'block'); }, function() { $("#login").fadeout('fast').css('display', 'none'); });
there's "hover out" part hover handler. i've tried fiddle , works.
Comments
Post a Comment