jquery - dynamically showing and hiding divs with javascript -
i have following code login system:
function handlelogin() { var e = $("#username").val(); var p = $("#password").val(); if(e != "" && p != "") { $.ajax({ type: 'post', url: 'http://localhost/php/log.php', crossdomain: true, data: {username: e, password :p}, datatype: 'json', async: false, success: function (response) { if (response.success) { alert("your login worked"); $('#logintest').html(e); } else { alert("your login failed"); } }, error: function(error) { alert('could not connect database' + error); } }); } else { alert("you must enter username , password"); } return false; } when login has worked, correct alert, want login div hide, , div beneath show username (e) in it.
so need work out how hide current div, show one.
the login div called #loginpage , div below called #logintest
you can use hide() , show():
if (response.success) { $('#loginpage').hide(); $('#logintest').show().html(e); } there fadein, fadeout, slideup, slidedown deal display/hiding of elements. use animate define own transition. api friend in these situations.
Comments
Post a Comment