(function(){ var LikeData = localStorage.getItem("like") == null ? [] : JSON.parse(localStorage.getItem("like")); function renderLike () { if(LikeData.length == 0) { $(".list-theme1").append("

没有收藏

") } else { LikeData.forEach(val => { $(".list-theme1").append(`

${val.title}

`) }); } } function BindTagaClick() { $("article a").on('click', function() { localStorage.setItem("info", JSON.stringify(LikeData[$(this).index()])) location.href="info.html" }); var $as = $('#J_ActionSheet'), index = null; $(".list-theme1 .list-item").on({ touchstart: function(e){ index = $(this).index() setTimeout(function(){ $as.actionSheet('open'); },500); } }); $('.delete-like').on("click",function() { LikeData.splice(index,1); localStorage.setItem("like", JSON.stringify(LikeData)); $("article a").eq(index).remove(); $as.actionSheet('close'); if(LikeData.length == 0) { $(".list-theme1").append("

没有收藏

") } }) $("#J_Cancel").on("click",function() { $as.actionSheet('close'); }) } renderLike() BindTagaClick() })()