简体   繁体   English

重复div元素n次

[英]repeat div element n times

how can i duplicate a div so there n copies using javascript or jquery this is the HTML div : 我如何复制一个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> 

and this is my jquery code but not working here what i want to do : 这是我的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"));

                     }

Not sure if appending a plain JQuery-object will work. 不知道是否可以添加普通的JQuery对象。 You better go with jQuery("#Guest_details_and_servicesDIV").append(jQuery("#Guest_details_and_servicesDIV"). html()); 最好使用jQuery(“#Guest_details_and_servicesDIV”)。append(jQuery(“#Guest_details_and_servicesDIV”)。html());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM