Jquery 克隆日期选择器值未在字段中选择
我尝试在克隆时在日期选择器列中选择一个日期,但每当我选择该日期时,它都不会被选择。它仅影响第一个父行。 克隆并且一切正常,并且每当我选择日期选择器时,它仅选择并仅在第一行中显示值。任何帮助将不胜感激。
$('.add_field_button').click(function () {
var ab = $('.row_duplicate_remove').clone(true);
var row_id =$('.row_duplicate:last').attr('row_id');
$('input.datefield').datepicker();
ab.attr('row_id',Number(row_id)+1)
ab.removeClass('row_duplicate_remove');
ab.find('.remove').show();
var nxt = Number(row_id)+1;
ab.find('.mydatepicker_new').attr('id','received_on_'+nxt);
ab.find('input,select').val('');
ab.find('#received_on_'+nxt).datepicker({
autoclose: true,
todayHighlight: true
});
$('.clonediv').append(ab);
event.preventDefault();
});
// Date Picker
jQuery('#received_on_1').datepicker({
autoclose: true,
todayHighlight: true
});
<button class="add_field_button btn btn-warning">Add</button>
<div class="input-group small-text w-100">
<input type="text" name="received_on" id="received_on_1" class="form-control mydatepicker_new" placeholder="--Select Date(s)--">
<div class="input-group-append">
<span class="input-group-text "><i class="fa fa-calendar"></i></span>
</div>
</div>
I have tried to select a date in the date picker column while cloning and whenever I select the date it is not getting selected. It affects only the first parent row. Cloning and all working fine, and whenever I select the date picker it only selects and shows the value only in the first row. Any help would be appreciated.
$('.add_field_button').click(function () {
var ab = $('.row_duplicate_remove').clone(true);
var row_id =$('.row_duplicate:last').attr('row_id');
$('input.datefield').datepicker();
ab.attr('row_id',Number(row_id)+1)
ab.removeClass('row_duplicate_remove');
ab.find('.remove').show();
var nxt = Number(row_id)+1;
ab.find('.mydatepicker_new').attr('id','received_on_'+nxt);
ab.find('input,select').val('');
ab.find('#received_on_'+nxt).datepicker({
autoclose: true,
todayHighlight: true
});
$('.clonediv').append(ab);
event.preventDefault();
});
// Date Picker
jQuery('#received_on_1').datepicker({
autoclose: true,
todayHighlight: true
});
<button class="add_field_button btn btn-warning">Add</button>
<div class="input-group small-text w-100">
<input type="text" name="received_on" id="received_on_1" class="form-control mydatepicker_new" placeholder="--Select Date(s)--">
<div class="input-group-append">
<span class="input-group-text "><i class="fa fa-calendar"></i></span>
</div>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这对我有用
This one worked for me