html代码
<label>上传日期:</label>
<div class="layui-input-inline" id="timediv">
<input type="datetime" style="width: 130px" class="layui-input" id="uplodData" placeholder="" value="" />
</div>
js
function layuikj(zqType) {
$("#uplodData").remove();//先将layui控件删掉
var timehtml = '<input type="datetime" style="width: 130px" class="layui-input" id="uplodData" placeholder="" value="" />';
$("#timediv").append(timehtml);//重新加载控件
layui.use(['laydate'], function () {
var laydate = layui.laydate;//日期
var lx = "";//类型
var gs = "";//格式
if (zqType == "日") {
lx = "datetime";
gs = "yyyy年MM月dd日";
} else if (zqType == "月") {
lx = "month";
gs = "yyyy年MM月";
}
else if (zqType == "年") {
lx = "year";
gs = "yyyy年";
} else {
lx = "datetime";
gs = "yyyy年MM月dd日";
}
//日期选择
var datekj = laydate.render({
elem: '#uplodData'
, max: Max()
, type: lx
, format: gs
});
});
}