Html中使用Cookie取值赋值
作者:互联网
//设置Cookie function setCookie(name, value) { var Days = 1; var exp = new Date(); exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000); document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString() + ";path:/"; } /* 获取Cookie中的值 */ function getCookie(objName) {//获取指定名称的cookie的值 var arrStr = document.cookie.split("; "); for (var i = 0; i < arrStr.length; i++) { var temp = arrStr[i].split("="); if (temp[0] == objName) { return decodeURI(temp[1]); } } }
需要引用jquery.cookie.js
标签:temp,arrStr,Html,Cookie,exp,var,cookie,取值 来源: https://www.cnblogs.com/ly-03-04/p/12088080.html