简体   繁体   English

单击恢复密码时,弹出式登录关闭

[英]Pop-up login close when clicked on recover password

With this code, when a user click inside my pop-up form this pop-up stay. 使用此代码,当用户在我的弹出式表单中单击时,此弹出式窗口会停留。 But when the user click in the ? 但是,当用户单击时? to recover the password the pop-up for that is showed, but doesnt close the login form. 要恢复密码,将显示弹出的密码,但不会关闭登录表单。

Any ideas how to close the login pop-up?? 任何想法如何关闭登录弹出窗口?

HTML Code: HTML代码:

   <div id="joinusLogin">
        <div id="backgroundOpacity"></div>
        <form id="loginForm">
            <input id="loginFormFields" type="email" name="email" placeholder=" E-mail"/><br />
                <input id="loginFormFields" type="text" name="password" placeholder=" Password"/>
                <div id="requestPassword">
                    <a href="javascript:hideshow(document.getElementById('passwordRecover'))">?</a>
                </div>
            <br />
                <input id="submitLogin" type="submit" value="LOG IN"/>
        </form>

        <div id="signupNow">
            Don't have an account yet? 
            <a href="javascript:hideshow(document.getElementById('inviteNowSignup'))">
                Sign up here.
            </a> 
        </div>
    </div>

    <div id="passwordRecover">
        <div id="backgroundOpacity"></div>
            <form id="passwordRecoverForm">
                <input id="passwordRecoverFields" type="email" name="email" placeholder=" E-mail"/><br />
                    <input id="submitPasswordRecover" type="submit" value="SEND PASSWORD"/>
            </form>

        <div id="signupNow">
            Don't have an account yet? 
            <a href="javascript:hideshow(document.getElementById('inviteNowSignup'))">
                Sign up here.
            </a> 
        </div>
    </div>

Javscript Code 邮政编码

function hideshow(which){
if (!document.getElementById)
    return
if (which.style.display=="block")
    which.style.display="none"
else
    which.style.display="block"
}

$('body').click(function(){
  $('#inviteNowSignup, #joinusLogin, #passwordRecover').hide();
});

$('body').on('click',"#signupForm, #loginForm, #passwordRecoverForm",function (e){
  e.stopPropagation();
});

As seen in your code. 如您的代码所示。 You have handled the opening and closing of those elements which have been clicked and passed to your function. 您已经处理了单击并传递给函数的那些元素的打开和关闭。 But you have not handled those which are already open. 但是您尚未处理已经打开的内容。

Try to add this line before the function 尝试在函数之前添加此行

   $('#inviteNowSignup, #joinusLogin').hide(); 

It will hide the other divs. 它将隐藏其他div。 BTW nice work with single function to hide and unhide. 顺便说一句,隐藏和取消隐藏的单个功能不错。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM