【发布时间】:2014-03-15 10:48:52
【问题描述】:
我已成功将 jquery UI datePicker 附加到动态创建的文本框,Al 工作正常,除非我选择的日期没有出现在相应的文本框中,但它出现在我的第一个不是动态创建的文本框中。我的代码是这样的
$(".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>
【问题讨论】:
-
试试jsfiddle.net/xUYM2(我只是使用更准确的元素指示来创建日期选择器)
-
啊哈..这就像一个魅力。你可以在这里添加这个作为答案:)
标签: javascript jquery html jquery-ui datepicker