这就是我要做的事情:
process.php
,它将存储在数据库中。我目前的代码:
$(document).ready(function () {
var counter = 1;
$("#add_row").click(function () {
new_elem = $("#addr_template").clone().appendTo("#container tbody")
.show().attr("id", "addr" + counter);
counter += 1;
});
});
现在,使用上面的代码(小提琴)我可以通过点击按钮添加多行,我有两个问题:
答案 0 :(得分:2)
在再次添加行之后,我已经包含了datepicker初始化。
$(document).ready(function () {
var counter = 1;
$("#add_row").click(function () {
new_elem = $("#addr_template").clone().appendTo("#container tbody").show().attr("id", "addr" + counter);
counter += 1;
$('#datepicker.input-daterange').datepicker({
format: "yyyy-mm-dd",
todayBtn: "linked",
autoclose: true,
todayHighlight: true
});
});
});
答案 1 :(得分:1)
更新Fiddle - 问题#1
$('#datepicker.input-daterange').datepicker({...});
在克隆表格行之后,也应该实现datepicker代码。在您的代码中,动态生成的行永远不会绑定到datepicker函数。