美文网首页
jquery.cookie

jquery.cookie

作者: 秋玄语道 | 来源:发表于2018-07-08 23:19 被阅读0次

    jquery.cookie的github地址

    <!DOCTYPE HTML>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script src="js/jquery.js" type="text/javascript"></script>
    <script src="js/jquery.cookie.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(document).ready(function() {
                    var COOKIE_NAME =  'username';
                    if($.cookie(COOKIE_NAME)){
                      $("#username").val($cookie(COOKIE_NAME));
                    }
                    $("#check").click(function(){
                       if(this.checked){
                          $.cookie(COOKIE_NAME,$("#username").val(),{path:'/',expires:10});
                       }else{
                          $.cookie(COOKIE_NAME,null,{path:''});
                       }
                    })
                    
                });
    
    </script>
    </head>
    <body>
       用户名:<input type="text" name="username" id="username"/> <br/>
       <input type="checkbox" name="check" id="check"/>记住用户名
    </body>
    </html>
    
    

    相关文章

      网友评论

          本文标题:jquery.cookie

          本文链接:https://www.haomeiwen.com/subject/vomauftx.html