jquery.cookie.js使用总结之页面之间传值
参照文章:https://blog.****.net/****_ds/article/details/78022177
定义:让网站服务器把少量数据储存到客户端的硬盘或内存,从客户端的硬盘读取数据的一种技术;
一、下载与引入:jquery.cookie.js基于jquery;先引入jquery,再引入:jquery.cookie.js;下载:http://plugins.jquery.com/cookie/
-
<script type="text/javascript" src="js/jquery.min.js"></script>
-
<script type="text/javascript" src="js/jquery.cookie.js"></script>
注意:此处必须是先1后2,否则无法使用cookie;
二、☆ jquerycookie怎样存入和读取数组?
不能直接存入数组,你可以转换为字符串存入;
1 2 3 4 5 6 7 8 9 10 11 12 |
|
三、JS向数组添加元素,插入数据
方式:
let myArray=[11,22,33];
console.log('原数组:',myArray);
myArray.push(44,55);
console.log('用push在数组后面插入元素:',myArray);
myArray.unshift(66,77);
console.log('用unshift在数组前面插入元素:',myArray);
myArray.splice(2,0,'肾虚少年');
console.log('用splice在数组指定位置插入元素:',myArray);
通过使用push以及unshift即可向数组插入元素,如果要在指定的位置插入元素则可以用splice,splice接收多个参数,分别是索引,要删除的元素个数,新加的元素(可多个,用逗号隔开);
这样即可向数组插入元素了。