zoukankan      html  css  js  c++  java
  • jq cookie

    //$.cookie("xx");//读取xx的值
    //$.cookie("xx","123");//设置xx的值为123
    //$.cookie("xx","123",{expires:7})//设置xx的值为123并保存7天 有效期为7天
    //$.cookie("xx","123",{expires:7,path:"/"})
    
    <script src="js/jquery.js"></script>
    <script src="js/jquery.cookie.js"></script>
    
    <input type="text" placeholder="用户名" id="txtName">
    <input type="password" placeholder="密码" id="txtPwd">
    <input type="checkbox" id="chkRememberPwd">记住密码
    <button>登录</button>
    
    <script>
    $(function () {
        $("#txtName").val($.cookie("name"));
        $("#txtPwd").val($.cookie("pwd"));
        if($.cookie("chkRememberPwd") == "1"){
            $("#chkRememberPwd").prop("checked","checked");
        }else{
            $("#chkRememberPwd").prop("checked","");
        }
        $("button").click(function(){
           var name = $("#txtName").val();
           var pwd = $("#txtPwd").val();
    
           if($("#chkRememberPwd").is(":checked")){
               console.log("2");
               $.cookie("name",name);
               $.cookie("pwd",pwd);
               $.cookie("chkRememberPwd","1");
           }else{
               $.cookie("name","");
               $.cookie("pwd","");
               $.cookie("chkRememberPwd","");
           }
        });
    })
    
    
    </script>
  • 相关阅读:
    课程个人总结
    构建之法阅读笔记06
    构建之法读后感5
    第五周进度条
    提高自身能力
    活动图与状态机图
    对分析业务模型----类图的学习与认识
    需求分析工作的基本道理
    问题账户需求分析
    2016秋季个人阅读计划
  • 原文地址:https://www.cnblogs.com/ss977/p/6599734.html
Copyright © 2011-2022 走看看