这是jquery的一部分:
var htmlTempItem2 = $('div[data-id="divPopupControl"] div[data-id="Detail"]').html();
$('div[data-id="divPopupControl"] div[data-id="Detail"] div[id="ItemDetails"] div[class="panel-collapse collapse"] ').remove();
$.map(data.d, function (item) {
console.log("round " + y);
var htmlAppend2 = jQuery("<div data-type='TempItem'></div>").html(htmlTempItem2)
.find('div[id="ItemDetails"]')
.attr('id' + y, 'ItemDetails' + y)
.html('')
.parents("div[data-type=TempItem] ").html();
$('div[data-id="divPopupControl"] div[data-id="Detail"]').append(htmlTempItem2);
$('div[data-id="divPopupControl"] div[data-id="Detail"]').find('div[id="ItemDetails"]')
.removeAttr('id').attr('id', 'ItemDetails' + y);
$('div[data-id="divPopupControl"] div[data-id="Detail"]').find('div[data-type="txtTitleNumber"]')
.removeAttr('data-type').attr('data-type' + y, 'txtTitleNumber' + y);
console.log("template : " + htmlTempItem2);
console.log("Current html : " + $('div[data-id="divPopupControl"] div[data-id="Detail"]').html()); y++;
这是HTML表单的一部分:
<div class="panel-group" data-id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingTwo">
<h4 class="panel-title">
<a id="Header" class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#ItemDetails" aria-expanded="false" aria-controls="ItemDetails">
Item Number #
</a>
</h4>
</div>
</div>
<div data-id="Detail">
<div id="ItemDetails" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
<div class="panel-body">
<div style="margin: 2px; background-color: white; padding: 10px; max-height: 500px; overflow:auto;">
<div class="spacer-custom"></div>
<div class="form-inline" role="form">
<div class="form-group col-xs-2 left">
<label class="control-label body-blue">Title No: </label>
</div>
<div class="col-xs-3">
<div data-type="txtTitleNumber"></div>
</div>
</div>
<div class="spacer-custom"></div>
<div class="form-inline" role="form">
<div class="col-xs-10" style="text-align:right">
<input type="button" class="btn btn-primary" data-id="btnClose" data-ResourceProviderKey="btnClose" data-dismiss="modal" />
<input type="button" class="btn btn-primary" data-id="btnSave" data-ResourceProviderKey="btnSave" />
</div>
</div>
</div>
</div>
</div>
</div>
</div>
大家好, 我可以在不同的调用TempItem生成中使用htmlTempItem和htmlTempItem2吗?我如何删除模板表单?因为这是用htmlTempItem循环
console.log("template : " + htmlTempItem2);
console.log("Current html : " + $('div[data-id="divPopupControl"] div[data-id="Detail"]').html());