如图:
代码:(需要将li中的样式属性display设置为inline-block)
//获取Url地址中的参数 function getParameter(name) { //正则表达式 var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; } function getData() { $.post("../catalog/GetProductByFactor", { storeId: getParameter("storeId") }, function (data) { var str = "<ul>"; for (var i = 0; i < data.length; i++) { str += "<li style = 'border:1px solid red;display:inline-block'>"; str += "<img src = '/upload/store/" + getParameter("storeId") + "/product/show/thumb60_60/" + data[i].showimg + "'/></li>"; str += "</li>"; } str += "</ul>"; $(".goods-right-bottom").append(str); }); }