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>
  • 相关阅读:
    移动端调试Vconsole
    Vue-返回顶部
    Vue-封装loading
    Vue-水印封装
    Vue-封装scroll触底
    微信小程序-图片上传
    前端面试题(2)
    前端常见面试题
    服务端渲染(SSR)和客户端(CSR)渲染的区别
    什么是模块化?模块化开发的好处
  • 原文地址:https://www.cnblogs.com/ss977/p/6599734.html
Copyright © 2011-2022 走看看