Copy Code code as follows:
<! DOCTYPE html>
<title>cookies.html</title>
<meta http-equiv= "keywords" content= "keyword1,keyword2,keyword3" >
<meta http-equiv= "description" content= "This are 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")) {
Value is assigned if present
$ ("#username"). Val ($.cookie ("name"));
}
$ ("#mycookie"). Submit (function () {
If you select the Save User name option
if ($ ("#chkSave"). Is (": Checked")) {
Set cookie Value
$.cookie ("Name", $ ("#username"). Val (), {
expires:7,//Set Save time
Path: "/"//Set the saved path
});
}else{
Destroying objects
$.cookie ("name", null,{
Path: "/"
});
}
return false;
});
});
</script>
<body>
<form action= "#" method= "Get" id= "MyCookie" >
<div>
User name:<br>
<input id= "username" name= "username" type= "text" class= "TXT" >
</div>
<div>
Password:<br>
<input id= "password" name= "password" type= "password" class= "TXT" >
</div>
<div>
<input id= "Chksave" type= "checkbox" > whether to save the user name
</div>
<div>
<input id= "cookbtn" class= "BTN" type= "Submit" value= "submitted" >
</div>
</form>
</body>