Home >Web Front-end >JS Tutorial >js implements the effect of hiding the login box when the check box selects anonymous login_javascript skills
The example in this article describes the js implementation of hiding the login box when the check box selects anonymous login. Share it with everyone for your reference. The details are as follows:
This technique is relatively common. Some websites allow you to log in to post or post anonymously. When you check the checkbox to post anonymously, the login box is automatically hidden. Is it more user-friendly? This is actually a little bit of JavaScript code added to the form element. Please see the code for the specific implementation method.
The operation effect is as shown below:
The online demo address is as follows:
http://demo.jb51.net/js/2015/js-checkbox-nm-login-submit-codes/
The specific code is as follows:
<title>当复选框选择匿名登录时隐藏登录框</title> <style>.a #login,#uname{display:none;}.a #uname{display:inline;}</style> <body> <div> <span id="login">帐号:<input type="text" /> 密码:<input type="text" /> <input type="submit" value="登录" /></span> <span id="uname">网友姓名:<input type="text" /></span> <input type="checkbox" id="check" onclick="this.parentNode.className=this.checked?'a':'';" />匿名</div> </body>
I hope this article will be helpful to everyone’s JavaScript programming design.