gpt4 book ai didi

javascript - 重复 div 元素 n 次

转载 作者:行者123 更新时间:2023-12-03 03:40:13 24 4
gpt4 key购买 nike

我如何复制 div 以便使用 javascript 或 jquery 有 n 个副本,这是 HTML div :

 <div id="Guest_details_and_servicesDIV" style="background-color: white;min-height: 128px;display:none;">
@{
int TotalNumberofPersons = Model.ViewModel_SessionObject.Parameters.SearchCriteria_NumberOfChildrenPerRoom +
Model.ViewModel_SessionObject.Parameters.SearchCriteria_NumberOfAdultsPerRoom;

}
@*<p style="margin-left: 27px;">Room1 : Deluxe Double Room / Best Available Rate </p>*@
<div style="max-width: 100%;width: 500px;border: 1px gray solid;margin-left: 46px;margin-top: 8px;">
<p>Guest names :</p>
<table style="width: 500px;">
@for (int i = 0; i < TotalNumberofPersons; i++)
{
<tr>
<td>
<select class="dropdown form-control" style="max-width: 75px;">
<option selected="selected">MR</option>
<option>MRS</option>
</select>
</td>
<td><input style="margin-left: -5px;" type="text" class="form-control" placeholder="prename" /></td>
<td><input type="text" class="form-control" placeholder="surname" /></td>
</tr>
}

</table>
</div>


<div style="border: 1px gray solid;max-width: 100%;width: 500px;margin-left: 46px;margin-top: 8px;">
<table class="vi_table" style="width: 500px;">
<tr class="pv" style="border: 1px gray solid;">
<td>services:</td>
<td></td>
</tr>

@foreach (var item in Model.ViewModel_SessionObject.HotelAvailabilityRSObject.Services)
{
HotelDetailsRSService HotelService = Model.ViewModel_SessionObject.HotelDetailsRSObject.GetHotelService(item.ServiceCode);
<tr class="pv" style="border: 1px gray solid;cursor: pointer;">
<td>@HotelService.Name :</td>
<td>@HotelService.Notes</td>
<td>
@HotelService.Price.ToString("N2")
@Model.ViewModel_SessionObject.HotelAvailabilityRSObject.CurrencyCode
</td>
<td><input type="checkbox" class="v_checkbox" /> </td>
</tr>
}

</table>

</div>
</div>

这是我的 jquery 代码,但在这里不起作用:

  for (var i = 0; i < Product.SelectedRooms; i++) {

$('#Guest_details_and_servicesDIV').show()

jQuery("#Guest_details_and_servicesDIV").append(jQuery("#Guest_details_and_servicesDIV"));

}

最佳答案

不确定附加普通 JQuery 对象是否有效。你最好使用 jQuery("#Guest_details_and_servicesDIV").append(jQuery("#Guest_details_and_servicesDIV").html());

关于javascript - 重复 div 元素 n 次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45661125/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com