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(""));    
        },

posted @ 2015-12-11 22:03  白金05  阅读(20271)  评论(0编辑  收藏  举报