jquery - 克隆日期选择器在 jquery 中不起作用
问题描述
这是我的代码,datepicker 不能在其中工作。
$(document).ready(function() {
var html = '<div id="element3"><div class="form-row"><div class="form-group col-md-3"><label for="exampleSelect1" class="bmd-label-floating">Providers</label><select class="form-control" id="exampleSelect1" name="carprovider[]"><option value="">--Select Type--</option><option value="1">1</option></select></div></div><input type="hidden" name="id"><div class="form-row"><div class="form-group col-md-3"><label for="exampleTextarea" class="bmd-label-floating">Pick Up Date</label><input type="text" class="form-control" id="datepicker-22" name="pickupdate[]"></div></div><div class="form-row"><div class="form-group col-md-3"><label for="exampleTextarea" class="bmd-label-floating">Pick Up Time</label><input type="text" class="form-control" id="datepicker-23" name="pickuptime[]"></div></div><div class="form-row"><div class="form-group col-md-3"><label for="exampleTextarea" class="bmd-label-floating">Drop Date</label><input type="text" class="form-control" id="datepicker-24" name="dropdate[]"></div></div><div class="form-row"><div class="form-group col-md-2"><label for="exampleTextarea" class="bmd-label-floating">Drop Time</label><input type="text" class="form-control" name="droptime[]"> </div></div><div class="form-row"><div class="form-group col-md-2"><label for="exampleTextarea" class="bmd-label-floating">Car Hire Type</label><input type="text" class="form-control" name="carhiretype[]"></div></div><div class="form-row"><div class="form-group col-md-2"><label for="exampleTextarea" class="bmd-label-floating">Ref No.</label><input type="text" class="form-control" name="refno[]"></div></div><div class="form-row"><div class="form-group col-md-2"><label for="exampleSelect1" class="bmd-label-floating">Currency</label><select class="form-control" id="exampleSelect1" name="currency[]"><option>--Select Type--</option><option value="gb">GB</option></select></div></div><div class="form-row"><div class="form-group col-md-2"><label for="exampleTextarea" class="bmd-label-floating">B. Price</label><input type="text" class="form-control" name="bprice[]"></div></div><div class="form-row"><div class="form-group col-md-2"><label for="exampleTextarea" class="bmd-label-floating">Price</label><input type="text" class="form-control" name="price[]"></div></div><button type="button" class="btn btn-secondary" id="cancel14">Cancel</button></div>';
var max = 5;
var x = 1;
$("#add14").click(function() {
if (x <= max) {
$("#element3").append(html);
x++;
}
});
$("#element3").on('click', '#cancel14', function() {
$(this).closest('div').remove();
x--;
});
});
解决方案
推荐阅读
- python - 如何在 VS Code 上将 Intellisense 用于 Selenium?
- c# - 在定义仅改变它们处理的参数的数据类型的函数类时,如何避免代码重复?
- bitmap - 位图 RLE 解压 'delta' 含义
- r - 从目录读取多个 xlsx 文件时 xlsx 包出错
- javascript - Tempus Dominus 未验证日期范围
- vue.js - 如何以正确的格式发出 momentjs 日期
- python - 训练变分自动编码器时,我收到“无法从 'keras.backend' 导入名称 'tensorflow_backend'”
- c# - 如何反序列化和加载序列化的 XAML UI 元素?
- python - 为 Flask 模板中所有未定义的 jinja2 变量设置默认值
- hazelcast - Hazelcast 谓词在子句中