代码之家  ›  专栏  ›  技术社区  ›  mare

jquery datepicker奇怪的问题

  •  0
  • mare  · 技术社区  · 15 年前

    为什么在一个地方使用此代码时会设置默认值,而在将前两个语句移到主文件中,将最后一个语句移到视图文件中时不会设置默认值(ASP.NETMVC应用程序)?

    $(function () {
    $(".editDate").datepicker({ dateFormat: 'dd.mm.yy' });
    $(".editDate").datepicker($.datepicker.regional['sl']);
    $("#IssueDate").datepicker('setDate', new Date()); // if I separate this one into it own file, it never sets the default date
    }); 
    

    ??

    1 回复  |  直到 15 年前
        1
  •  0
  •   Kelly    15 年前

    在没有看到其余代码的情况下,我猜您正在尝试在调用js之前调用“setDate”,js实际上将您的输入转换为日期选择器。