我正在尝试在一周前克隆一个日期选择器,当我得到它或者克隆功能不起作用,或者使用datepicker函数时,我希望他们可以帮助我!谢谢
从博客中删除代码
<script type="text/javascript">
$(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.children(':first').attr('id', 'name' + newNum).attr('name', 'name' + newNum);
$('#input' + num).after(newElem);
$('#btnDel').attr('disabled','');
if (newNum == 5)
$('#btnAdd').attr('disabled','disabled');
});
$('#btnDel').click(function() {
var num = $('.clonedInput').length;
$('#input' + num).remove();
$('#btnAdd').attr('disabled','');
if (num-1 == 1)
$('#btnDel').attr('disabled','disabled');
});
$('#btnDel').attr('disabled','disabled');
});
</script>
PróximosPasos
<input type="button" id="btnDel" value="x" class="btn btn-default"/>
<input type="button" id="btnAdd" value="+" class="btn btn-primary"/>
</div>
<div class="col-md-4">
<input type="text" class="form-control" id="proximospasos1" name="proximospasos1" required value="" placeholder="Próximos Pasos">
</div>
<div class="col-md-4">
<input type="text" class="form-control" id="participantes1" name="participantes1" required value="" placeholder="Participantes">
</div>
<div class="col-md-2">
<div class="input-group date">
<input type="text" class="form-control date" id="fecha2" name="fecha2"/>
<span class="input-group-addon">
<i class="fa fa-calendar" aria-hidden="true"></i></span>
</div>
</div>
</span>
</div>
答案 0 :(得分:0)
试试这个
更改此行:
var newElem = $('#input' + num).clone().attr('id', 'input' + newNum);
对此:
var newElem = $('#input' + num).clone().datepicker().attr('id', 'input' + newNum);