I'm doing a popup login form with css and jQuery.
The login popup's right, but my problem is... the only way of close the popup is pressing the submit button. Why it does not close when user clicks then mask or in the close image.
I'm getting crazy with this...
Please help me!!
The code: http://jsfiddle.net/XZAmn/
html:
<br />
<a class="btn-sign" href="#login-box">login</a>
<div id="login-box" class="login-popup"> <a href="#" class="btn_close">
<img src="http://www.alisol.com.br/crm/imagens/close_pop_blue.png?v=4" class="btn_close" title="Fechar" alt="Fechar" /></a>
<form method="post" class="signin" action="#">
<fieldset class="textbox">
<h3>LOGIN</h3>
<label class="username">
<input id="username" name="username" value="" type="text" autocomplete="on" placeholder="usuário">
</label>
<label class="password">
<input id="password" name="password" value="" type="password" placeholder="senha">
</label>
<input id="enter" type="submit" value="Entrar" />
</fieldset>
</form>
javascript:
$(document).ready(function() {
$('a.btn-sign').click(function() {
// Getting the variable's value from a link
var loginBox = $(this).attr('href');
//Fade in the Popup and add close button
$(loginBox).fadeIn(300);
//Set the center alignment padding + border
var popMargTop = ($(loginBox).height() + 24) / 2;
var popMargLeft = ($(loginBox).width() + 24) / 2;
$(loginBox).css({
'margin-top' : -popMargTop,
'margin-left' : -popMargLeft
});
// Add the mask to body
$('body').append('<div id="mask"></div>');
$('#mask').fadeIn(300);
return false;
});
// When clicking on the button close or the mask layer the popup closed
$('a.close, #mask').click( function() {
$('#mask, .login-popup').fadeOut(300 , function() {
$('#mask').remove();
});
return false;
});
});