小编ree*_*man的帖子

DatePicker:当多个数组 id 时无法设置未定义的属性“currentDay”

我在动态行表中遇到日期选择器的问题。

  • 如果输入字段的 id 插入索引(例如:)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)

html javascript php jquery datepicker

5
推荐指数
1
解决办法
6382
查看次数

标签 统计

datepicker ×1

html ×1

javascript ×1

jquery ×1

php ×1