效果:
加入资源:
<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css"/>
$("tr[id=\'"+i+"\']")
.replaceWith("<tr id="+(i-1)+" align='center'>"
// +"<td>"+(i-1)+"</td>"
// +"<td>Dynamic TR"+(i-1)+"</td>"
+"<td><div>开始日期<input type='text' value='2020-05-11' placeholder='' name='dataDemandStatisticsCycleStart"+(i-1)+"' id = 'dataDemandStatisticsCycleStart"+_len+"' style='width: 70px' onchange='dateRangePickIndex("+(i-1)+")'></div>" +
"<div>结束日期<input type='text' value='2100-12-31' placeholder='' name='dataDemandStatisticsCycleEnd"+(i-1)+"' id = 'dataDemandStatisticsCycleEnd"+_len+"' style='width: 70px' onchange='dateRangePickIndex("+(i-1)+")'></div></td>"
+"<td><input type='text' name='dataDemandStatisticsCycles"+(i-1)+"' value='"+nextTxtVal+"' id='dataDemandStatisticsCycles"+(i-1)+"' style='width: 140px' disabled='disabled'/></td>"
+"<td><a href=\'#\' onclick=\'deltr("+(i-1)+",1)\'>删除</a></td>"
+"</tr>");
dataDemandStatisticsCyclePicker(i-1);
function dataDemandStatisticsCyclePicker(index) {
$(function(){
$("input[name='dataDemandStatisticsCycleStart"+index+"']").daterangepicker({
singleDatePicker:true,
showDropdowns:true,
locale: {
format: "YYYY-MM-DD",
daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
monthNames: ['一月', '二月', '三月', '四月', '五月', '六月',
'七月', '八月', '九月', '十月', '十一月', '十二月'
],
firstDay: 1
},
},
function(start,end,label){
});
});
$(function(){
$("input[name='dataDemandStatisticsCycleEnd"+index+"']").daterangepicker({
singleDatePicker:true,
showDropdowns:true,
locale: {
format: "YYYY-MM-DD",
daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
monthNames: ['一月', '二月', '三月', '四月', '五月', '六月',
'七月', '八月', '九月', '十月', '十一月', '十二月'
],
firstDay: 1
},
},function(start,end,label){
});
});
}