js里的數組push用法及append()


result.result[0].name

var arr = new Array();
$.each(result.result, function(i, item) {
            arr.push("<li onclick=\"tiaoZhuan('"+item.id+"')\">");
            arr.push("<div class=\"shopList-ima\">");
            arr.push("<img src=\"${ctx }/static/wx/images/shopima.png\" alt=\"門店圖片\"/>");
            arr.push("</div> <div class=\"shopList-txt\">");
            arr.push("<h3>"+item.customername+"</h3>");
            arr.push("<p>評價<img src=\"${ctx }/static/wx/images/star.png\" alt=\"門店評價\"/></p>");
            arr.push("<p>"+item.address+"</p>");
            arr.push("<p>電話:"+item.tel+"</p>");
            arr.push("</div></li>");
            });
            $("#shopid").append(arr.join(""));    
        },


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM