css - jQuery .show() only works for a split second -
i have div
<div id="fade_bg"> <div id="login_div"> <form action="../classes/login/authenticator.php" method="post"> <p>username: <input type="text" name="username" /></p> <p>password: <input type="password" name="password" /></p> <p><input type="submit" name="login" /></p> </form> <p><a id="cancel" href="#">cancel</a> </div> </div>
that want show when
<a id="login" href="">admin login</a>
is clicked. used
$(function() { $('a#login').click(function() { $('#fade_bg').show(); $('#login').hide(); }); $('a#cancel').click(function() { $('#fade_bg').hide(); $('#login').show(); }); });
however, when click link, div want appear appears split second, returns normal if clicked cancel button. why happening?
edit: no errors on js debugger console.
try this:
$('#login').click(function (e) { e.preventdefault(); $('#fade_bg').show(); $(this).hide(); }); $('#cancel').click(function (e) { e.preventdefault(); $('#fade_bg').hide(); $('#login').show(); });
Comments
Post a Comment