Cookie完整的公用封装方式 2018-08-20 技术开发 123456789101112131415161718192021222324var Cookie-function = { setCookie: function(name, value) { //写cookies var d = new Date(); d.setTime(d.getTime() + (7 * 24s * 60 * 60 * 1000)); var expires = "expires=" + d.toUTCString(); document.cookie = name + "=" + value + "; " + expires; }, getCookie: function(cname) { //读取cookies var name = cname + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1); if (c.indexOf(name) != -1) return c.substring(name.length, c.length); } return ""; }, delCookie: function(name) { //删除cookies f.setCookie(name, "", -1); },} 前一篇 通过Swiper插件简单实现div大部分的滑动功能 后一篇 如何为一个大div边框添加一个小三角形