您的位置:首页 > Web前端 > JQuery

简易的JQuery设置Cookie

2015-11-09 09:57 531 查看
使用之前先引用这两个文件:



然后基本的功能代码如下:

<div>
<input id="txtDelValues" type="text" />
<input id="Button1" type="button" onclick="SetCookie();" value="设置cookie" />
<input id="Button2" type="button" onclick="javascript: alert(GetCookie());" value="显示cookie" />
<input id="Button3" onclick="DelCookie()" type="button" value="删除cookie" />
</div>

<script type="text/javascript">
//设置COOKIE
function SetCookie() {
$.cookie("test", $('#txtDelValues').val());
}
//读取Cookie
function GetCookie() {
if ($.cookie('test') != null) {
var res = $.cookie('test');
return res;
} else {
return null;
}
}
//删除Cookie
function DelCookie() {
$.cookie('test', null);
}
</script>


更多详细内容,请参考: http://www.helloweba.com/view-blog-86.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: