I have successfully attached jquery UI datePicker to a dynamically created textbox, Al works fine excepts when I select a date it is not coming in corresponding textbox, But it comes in my first textbox which is not dynamically created. My code is like this
$(".add-more").click(function () {
$this = $(this);
$section = $($("." + $this.attr("data-section"))[0]).html();// This is a section in my HTML with multiple textboxes
$this.parent().append('<div class=' + $this.attr("data-section") + '>' + $section + '</div>').fadeIn();
$(".datepicker").removeClass('hasDatepicker').datepicker();
});
HTML
<div id="Div1" class="section-container">
<div class="education-item" style="display: none">
<p>Institute:<input type="text" name="txtInstitute" /></p>
<p>Start Year:<input type="text" name="txtStartYear" class="datepicker" /></p>
<p>End Year:<input type="text" name="txtEndYear" class="datepicker"/></p>
</div>
</div>