欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery的cookie插件實(shí)現(xiàn)保存用戶登陸信息

 更新時(shí)間:2014年04月15日 16:16:04   作者:  
保存用戶登陸信息的方法有很多,本文為大家介紹的這個(gè)方法是通過cookie插件來實(shí)現(xiàn),需要的朋友可以參考下
復(fù)制代碼 代碼如下:

<!DOCTYPE html>
<html>
<head>
<title>cookies.html</title>

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<style type="text/css">
.txt{
width: 150px;
height:20px;
border: 1px blue solid;
border-radius:0.5em;
margin-bottom: 5px;
padding-left: 5px;
}

</style>
<script type="text/javascript" src="../js/jquery-1.10.2.js"></script>
<script type="text/javascript" src="../js/jquery.cookie.js"></script>
<script type="text/javascript">
$(function(){


if($.cookie("name")){
//取值如果存在則賦值
$("#username").val($.cookie("name"));

}


$("#mycookie").submit(function(){

//如果選中了保存用戶名選項(xiàng)
if($("#chkSave").is(":checked")){

//設(shè)置Cookie值
$.cookie("name",$("#username").val(),{
expires:7,//設(shè)置保存期限
path:"/"http://設(shè)置保存的路徑

});

}else{

//銷毀對(duì)象
$.cookie("name",null,{
path:"/"

});
}

return false;
});

});


</script>
</head>
<body>
<form action="#" method="get" id="mycookie">

<div>
用戶名:<br>
<input id="username" name="username" type="text" class="txt">
</div>
<div>
密碼:<br>
<input id="password" name="password" type="password" class="txt">
</div>
<div>
<input id="chkSave" type="checkbox">是否保存用戶名
</div>
<div>
<input id="cookBtn" class="btn" type="submit" value="提交">
</div>

</form>
</body>
</html>

相關(guān)文章

最新評(píng)論