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(); }); 

demo here


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -