我需要动态创建以下HTML
<div role="main" class="ui-content oms-content">
<div class="myactivelabelsWrap">
<div data-role="collapsible" data-inset="false">
<h3>Home <a class="icon-pencil-1 labelEditIcon"></a></h3>
</div>
<div data-role="collapsible" data-inset="false">
<h3>SoftSol <a class="icon-pencil-1 labelEditIcon"></a></h3>
</div>
</div>
<div class="row">
<button class="btn btn-a">Create New Label</button>
</div>
</div>
我是这样尝试的
首先,我在HTML中定义了以下内容
<div role="main" class="ui-content oms-content">
<div class="row">
<button class="btn btn-a">Create New Label</button>
</div>
</div>
这是我的小提琴
var response =
{
"Restaurants": [
{
"RestrntArea": "Home",
"cust_loc_id": "338"
},
{
"RestrntArea": "Soft",
"cust_loc_id": "339"
}
]
}
showLabels();
function showLabels() {
var labelsdivtemp=$('<div class="myactivelabelsWrap"></div>');
for (var i = 0; i < response.Restaurants.length; i++) {
var name = response.Restaurants[i].RestrntArea;
if(name)
{
labelsdivtemp.append('<div data-role="collapsible" data-inset="false"><h3>'+name+'<a class="icon-pencil-1 labelEditIcon"></a></h3></div>');
}
}
$("#labelsdivheader").append(labelsdivtemp);
}
我的问题是如何将创建新标签移到最后?
答案 0 :(得分:1)
答案 1 :(得分:1)
答案 2 :(得分:0)