(function () { if (window.localStorage) { if (!localStorage.arrRed) { localStorage.arrRed = "[0,0,0,0]"; } var navData = ['2018/11/05', '2018/08/08', '2018/11/05', '2018/07/08', '2018/11/05']; var time = new Date().getTime(); var arrRed = JSON.parse(localStorage.arrRed); for (var item in navData) { var arrTemp = Date.parse(navData[item]) + 86400000; if (time < arrTemp && navData[item] != arrRed[item]) { Zepto("#mainNav .item").eq(item).addClass("red"); } } Zepto("#mainNav .red a").each(function (index) { Zepto(this).attr("hrefData", Zepto(this).attr("href")); Zepto(this).attr("href", "javascript:;"); }); Zepto("#mainNav .red").on("click", function () { arrRed[Zepto(this).index()] = navData[Zepto(this).index()]; localStorage.arrRed = JSON.stringify(arrRed); location.href = Zepto(this).find("a").attr("hrefData"); }); } })();