【问题标题】:multiple JQuery datepicker fields多个 JQuery 日期选择器字段
【发布时间】:2016-04-25 14:17:57
【问题描述】:

我有一个包含多个 JQuery datepicker 字段的表单,但问题是前 2 个字段仅有效,其余无效,我搜索并找到 this,但没有帮助。这是我的代码:

$('.datePicker').datepicker({
changeYear: true,
changeMonth: true,
autoSize: true,
dateFormat: "dd-mm-yy",
maxDate: "0y",
showAnim: "show",
yearRange:'c-70:c+0',

});

HTML:

<input type="text" class='datePicker' name='startDate' ><span><img alt="" src="${assetPath(src: 'calendar-icon.png')}"/></span>
<input type="text" class='datePicker' name='endDate' ><span><img alt="" src="${assetPath(src: 'calendar-icon.png')}"/></span>

【问题讨论】:

  • 只要他们都有 .datePicker 类,它应该可以工作。不需要循环,因为插件无论如何都会在内部执行此操作。
  • @adeneo ,这是假设发生的事情,但我不知道出了什么问题
  • 你只发布了两个字段,看起来像to work just fine,其他字段是什么样的?
  • @adeneo,这两个字段重复了 4 次。这些都是与日期选择器相关的所有字段
  • 这似乎还是work just fine,所以肯定有其他问题?

标签: javascript jquery jquery-ui datepicker


【解决方案1】:

试试这个:

$('.datePicker').each(function(){
    $(this).datepicker({
    changeYear: true,
    changeMonth: true,
    autoSize: true,
    dateFormat: "dd-mm-yy",
    maxDate: "0y",
    showAnim: "show",
    yearRange:'c-70:c+0',
    });
});

【讨论】:

  • 没有帮助,还是同样的问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多