我在动态行表中遇到日期选择器的问题。
price_date[0]它是有效的。price_date[],它将创建错误无法设置currentDay未定义的属性。datepicker 是显示但点击日期时会显示错误。price_date[]不显示错误。i = parseInt($('#counter').val());
$("#add_row").click(function(){
$('#addr'+i).html("<td align='right'>"+ (i+1) +"</td>\
<td class='col-xs-2'>\
<input type='text' name='harga_start_date[]' id='harga_start_date[]' class='datepick form-control' >\
</td>");
$('#tab_logic').append('<tr id="addr'+(i+1)+'"></tr>');
i++;
});
$("#delete_row").click(function(){
if(i> 1){
$("#addr"+(i-1)).html('');
i--;
}
});
$(document).on('focus',".datepick", function(){
$(this).datepicker({
dateFormat : 'yy-mm-dd',
changeMonth: true,
changeYear: true
});
}); Run Code Online (Sandbox Code Playgroud)
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<table class="table table-striped" id="tab_logic">
<thead>
<tr>
<td colspan="7">
<a …Run Code Online (Sandbox Code Playgroud)