jquery如何删除本地cookie

使用jquery删除本地cookie的方法:1.新建html项目,引入jquery;2.引入cookie插件;3.使用$.cookie()方法创建cookie;4.通过将cookie设置为null删除cookie;

具体步骤如下:

1.首先,新建一个html项目,并在项目中引入jquery;

<script type="text/javascript" src="/static/jquery-2.1.4.min.js"></script>

2.引入jquery后,继续在项目中引入cookie插件;

<script src="jquery.cookie.js></script>

3.cookie插件引入后,使用$.cookie()方法创建一个cookie;

$(function(){

$.cookie("hello","world!");

console.log($.cookie("hello"));

});

4.最后,cookie创建好后,通过将cookie设置为null即可删除指定的cookie;

$(function(){

$.cookie("hello","world!");

console.log($.cookie("hello"));

$.cookie("hello",null); //删除hello

console.log($.cookie("hello"));

});

Both comments and pings are currently closed.

Comments are closed.

Powered by KingAbc | 粤ICP备16106647号-2 | Loading Time‌ 0.251