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>
网友评论