码迷,mamicode.com
首页 > 编程语言 > 详细

localStorage中js数组的存储和读取

时间:2015-05-29 17:11:19      阅读:242      评论:0      收藏:0      [点我收藏+]

标签:

   var old_destid = localStorage.getItem(‘destid‘);
        if (!old_destid) {
            var destids = [];
            destids.push(destid)
        } else {
            var destids = old_destid.split(‘,‘);
            if ($.inArray(‘<?= $destid ?>‘, destids) == ‘-1‘) {
                destids.push(destid)
            }
        }
        localStorage.setItem(‘destid‘, destids.join(‘,‘));//保存数据

 

  var old_destid = localStorage.getItem(‘destid‘);
                if (old_destid) {
                    var destids = old_destid.split(‘,‘);
                    var dest_stu = $.inArray(‘‘ + dest.destid + ‘‘, destids) >= 0 ? ‘yicanguan‘ : ‘weicanguan‘;
                }

localStorage中js数组的存储和读取

标签:

原文地址:http://www.cnblogs.com/YTzZ/p/4538659.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!