使用Javascript。 .append

问题描述 投票:-2回答:1

HTML。

<div id="listsalon">
   <ul data-role="listview" data-inset="true" data-filter="true" >

   </ul>
</div>

JS。

for (var i = 0; i < arr.length; i++) {

   companyname = arr[i].CompanyName;

   picture = arr[i].Picture;

   address = arr[i].Address;

   $("#listsalon ul").append("<li class='ui-corner-all'>" + 
                        "<a id=" + '"' + "salon" + (i + 1) + '"' + "><img src='" + picture +           
                        "'style='height:160px; width:200px;' class='ui-corner-all'>" +
                        "<h2 style='font-size:13px'>" + companyname + "</h2>" +
                        "<p style='font-size:10px'>" + address + "</p>" +
                       "</a></li>");
                }

    $("#salon1").bind("click", function () {
        window.location = "salon.html"
    });
javascript jquery html dom append
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.