教程集 www.jiaochengji.com
教程集 >  jQuery  >  jquery 教程  >  正文 cookie的复制与使用记住用户名实现代码

cookie的复制与使用记住用户名实现代码

发布时间:2014-04-29   编辑:jiaochengji.com
正如标题所言cookie如何复制、使用与记住用户名,下面有个不错的示例,感兴趣的朋友可以参考下
复制代码 代码如下:

<!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>
<title></title>
<script src="Scripts/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="Scripts/jquery.cookie.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
if ($.cookie("username")) {
$("#user").val($.cookie("username"));

}

$("#login").click(function () {
$.cookie("username", $("#user").val(), { expires: 7 }); //{ expires: 7 }的意思是让cookie保存7天
})
})
</script>
</head>
<body>
<input type="text" id="user" />
<input type="button" id="login" value="提交" />
</body>
</html>

您可能感兴趣的文章:
cookie的复制与使用记住用户名实现代码
jquery.cookie.js 操作cookie实现记住密码功能的实现代码
jquery记住用户名与密码实现方法
php cookie实现记住用户名与密码的代码(图文)
asp.net操作cookie详解
jquery cookie 与asp.net实现登录记住用户名密码
servlet与jsp基础教程(9)-处理Cookie
php利用$_COOKIE实现自动登录程序代码
ASP Cookies 教程
js判断用户名cookie是否存在

关键词: cookie  记住用户名   
[关闭]
~ ~