带有 2 个日期选择器的克隆表单
我正在尝试使用日期选择器克隆具有两个不同文本字段的表单。我一直在这里寻找答案,但能找到像我这样的答案。
$(document).ready(function() {
$('#btnAdd').click(function() {
var num = $('.clonedInput').length;
var newNum = new Number(num + 1);
var newElem = $('#input' + num).clone().attr('id', 'input' + newNum);
newElem.find('#label_cl label').attr('for' , 'label_cl' + newNum);
newElem.find('#input_cl input').attr('id' , 'input_cl' + newNum);
newElem.find('#label_cls label').attr('for' , 'label_cls' + newNum);
newElem.find('#input_cls input').attr('id' , 'input_cls' + newNum);
$('#input' + num).after(newElem);
$('#input_cl' + newNum ).datepicker;
$('#input_cls' + newNum ).datepicker;
I am trying to clone a form with two different texfields with datepicker. I have being searching for answeres here but coulnd find anything like mine.
$(document).ready(function() {
$('#btnAdd').click(function() {
var num = $('.clonedInput').length;
var newNum = new Number(num + 1);
var newElem = $('#input' + num).clone().attr('id', 'input' + newNum);
newElem.find('#label_cl label').attr('for' , 'label_cl' + newNum);
newElem.find('#input_cl input').attr('id' , 'input_cl' + newNum);
newElem.find('#label_cls label').attr('for' , 'label_cls' + newNum);
newElem.find('#input_cls input').attr('id' , 'input_cls' + newNum);
$('#input' + num).after(newElem);
$('#input_cl' + newNum ).datepicker;
$('#input_cls' + newNum ).datepicker;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您还需要使用日期选择器实例化新输入,将:更改
为
You need to instantiate the new input with a datepicker too, change:
to
这不是初始化日期选择器插件的方式。
将其更改为
您必须调用
datepicker
插件,以便它将在输入元素上应用必要的事件处理程序。This is not the way you initialize datepicker plugin.
Change it to
You have to call
datepicker
plugin so that it will apply the necessary event handlers on the input element.