1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
[html] <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>登录</title> <link rel="stylesheet" type="text/css" href="./style/style.css"> <script type="text/javascript" src="./js/jquery-1.7.2.js" ></script> <script type="text/javascript" src="./js/jquery.cookie.js" ></script> </head> <body class="kckp-login"> <div class="login-mod"> <div class="login-mod-logo"> <img src="./images/login-mod-logo.png" /> </div> <div class="login-mod-box"> <div class="login-mod-name"> <input type="text" name="username" value="" placeholder="请输入用户名" class="login-username" /> </div> <div class="login-mod-pwd"> <input type="password" name="password" value="" placeholder="请输入密码" class="login-password" /> </div> <div class="login-mod-rem"><input class="save-pwd" type="checkbox" name="" value="" />记住密码</div> <a href="javascript:" class="login-mod-submit" onclick="Save();">登陆</a> </div> </div> <script type="text/javascript" > $(document).ready(function(){ if($.cookie("rmbUser") == "true"){ $(".save-pwd").attr("checked", true); $(".login-username").val($.cookie("username")); $(".login-password").val($.cookie("password")); } }); //记住用户名密码 function Save(){ if($(".save-pwd").attr("checked")){ var username = $(".login-username").val(); var password = $(".login-password").val(); $.cookie("rmbUser", "true", {expires: 7});//存储一个带7天期限的cookie $.cookie("username", username, {expires: 7}); $.cookie("password", password, {expires: 7}); }else{ $.cookie("rmbUser", "false", {expires: -1}); $.cookie("username", "", {expires: -1}); $.cookie("password", "", {expires: -1}); } } </script> </body> </html> [/html] |
下载:jquery记住账号密码