当前位置:编程学习 > JAVA >>

jq cookie

[javascript]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>jqCookie保存用户名</title> 
<script language="javascript" type="text/javascript" src="jsBank/jquery-1.4.2.js"></script> 
<script language="javascript" type="text/javascript" src="jsBank/jquery.cookie.js"></script> 
<script language="javascript" type="text/javascript"> 
    $(function(){ 
        if($.cookie("UserName")){ 
            $("#userName").val($.cookie("UserName")+"保存"); 
        } 
        $("#btLogin").click(function(){ 
            $.cookie("UserName",$("#userName").val(),{expires:7}); 
            //expires 可以设定保存时间{expires:7,path:'/',domain:'itcast.cn',secure:true}  
         
        }); 
    }); 
</script> 
</head> 
 
<body> 
<label>姓名:<input type="text" id="userName" /></label><p> 
<label>密码:<input type="password" id="pw" /></label><br /> 
<input type="button" id="btLogin" value="登录"/> 
</body> 
</html> 
补充:web前端 , JavaScript ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,