[英]Add new row dynamically bootstrap-datetimepicker not working
I have a table: 我有一张桌子:
<tr>
<td><div class="form-group"><div id="date" class="input-group date"><input type="text" class="form-control"><span class="input-group-addon"><span class="glyphicon-calendar glyphicon"></span></span></div></div></td>
<td><a href="#" class="btn btn-danger btn-sm"><span class="glyphicon glyphicon-trash"></span></a></td>
</tr>
I use the button to create a new row dynamically: 我使用按钮动态创建新行:
$("#addInt").click(function() {
$("#intTbl").each(function () {
var tds = '<tr>';
$.each($('tr:last td', this), function () {
tds += '<td>' + $(this).html() + '</td>';
});
tds += '</tr>';
if ($('tbody', this).length > 0) {
$('tbody', this).append(tds);
} else {
$(this).append(tds);
}
});
});
I use bootstrap-datetimepicker
to create date field in the form, but when I dynamically add a new row, the date field is not working. 我使用
bootstrap-datetimepicker
在表单中创建日期字段,但是当我动态添加新行时,日期字段不起作用。
Try this : 尝试这个 :
<tr>
<td><div class="form-group"><div class="input-group date"><input type="text" class="form-control"><span class="input-group-addon"><span class="glyphicon-calendar glyphicon"></span></span></div></div></td>
<td><a href="#" class="btn btn-danger btn-sm"><span class="glyphicon glyphicon-trash"></span></a></td>
</tr>
$('body').on('focus',".date", function(){
$(this).datetimepicker();
});
Instead of : 代替 :
$('#date').datetimepicker();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.