js跟jQuery 添加、删除、获取cookie
js和jQuery 添加、删除、获取cookie? ? ? ? ? ? ? ? ? ?在jquery.cookie.js中 jquery.cookie是一个轻量级的c
js和jQuery 添加、删除、获取cookie
? ? ? ?
? ? ? ? ? ?在jquery.cookie.js中 jquery.cookie是一个轻量级的cookie插件,可实现cookie添加、删除、读取。
? ? ? ? ? ? ? ? ? ?首先引用jQuery文件:
? ? ? ? ? ?
?
? ? ? ? ? ? 1、添加cookie
Contains flags for the useragent, read from navigator.userAgent.Available flags are:safari
opera
msie
mozilla
This property is available before the DOM is ready, therefore you can use it to add ready events only for certain browsers.
There are situations where object detection is not reliable enough, in such cases it makes sense to use browser detection.
?
function clearCookie(){ var keys=document.cookie.match(/[^ =;]+(?=\=)/g); if (keys) { for (var i = keys.length; i--;) document.cookie=keys[i]+'=0;expires=' + new Date( 0).toUTCString() } } ?? ? ? ? ? ? ? ? ? ? ? ??