I have a div
which contains a a dropdown with data bound to it and an input
type text datepicker and a textbox. I want to make a clone of the div
with a new id
of clone
, input type date picker, textbox and dropdownlist and bound data to cloned dropdown. How can I do this?
I'm using the below code it cloning it changing the id of div but not its child elements and the cloned input type text date picker gets disabled.
var toAddCloneCount = 0;
function AddDestination() {
var clone = $("#toAdd").clone(true);
clone.show();
clone.attr('id', 'toAdd' + toAddCloneCount++).insertAfter("#toAdd");
clone.find("#days").attr('id', 'days' + toAddCloneCount);
clone.appendTo("#destinations");
}
<div id="destinations">
<div id="toAdd">
<table style="width: 100%;">
<tr>
<td class="auto-style8">To </td>
<td>
<asp:DropDownList ID="dropDownList2" runat="server" onchange="CheckCity()" DataValueField="CityId" DataTextField="CityName" Height="100%" Width="95%"></asp:DropDownList>
</td>
<td>Days to Stay</td>
<td>
<asp:TextBox ID="days" Width="30%" Height="100%" onkeypress="return false" onKeyDown="return false" TextMode="Number" Min="1" runat="server" Text="1"></asp:TextBox>
</td>
<td>
<p>
Date:
<input type="text" class="getCurrentDate" id="toDate" onkeypress="return false" onkeydown="return false" />
</p>
</td>
<td>
<asp:LinkButton ID="LinkButton2" OnClientClick="AddDestination(); return false;" CssClass="divshow" runat="server">+Add</asp:LinkButton>
</td>
</tr>
</table>
</div>
</div>