【问题标题】:jQuery: datepicker - Calendar activated by the icon and the date field at the same timejQuery: datepicker - 通过图标和日期字段同时激活的日历
【发布时间】:2010-04-20 17:43:00
【问题描述】:

我已经环顾四周,但找不到我现在遇到的确切解决方案/问题。

我只想通过单击日历图标和选择日期时显示日期的文本字段来显示日历。现在,在尝试了不同的属性之后,我只能让日历显示其中之一,但不能同时显示:图标和字段。

这是我用来通过图标激活它的代码:

$("#datepicker").datepicker({
   showOn: 'button',
   buttonImage: 'images/icon-calendar.gif',
   buttonImageOnly: true,
   changeMonth: true,
   changeYear: true,
   showAnim: 'slideDown',
   duration: 'fast'
});

有没有办法通过点击图标和字段来显示日历?

谢谢。

【问题讨论】:

    标签: jquery datepicker


    【解决方案1】:

    这是在单击图标和日期字段时显示日历的工作代码,请注意“两者”值:

    $("#datepicker").datepicker({
     showOn: 'both',
     buttonImage: 'images/icon-calendar.gif',
     buttonImageOnly: true,
     changeMonth: true,
     changeYear: true,
     showAnim: 'slideDown',
     duration: 'fast'
    });
    

    感谢德里克的帮助。

    【讨论】:

      【解决方案2】:

      尝试设置:showOn: 'both'

      【讨论】:

      • 噢!如此简单,但插件页面中没有对此的解释。非常感谢德里克,它奏效了!不过我还不能投票 :(,一旦我有足够的声望点就会投票给你。
      • 没问题,我第一次使用 datepicker 时也遇到了这个问题。
      【解决方案3】:

      给你的日期选择器字段一个 id 并试试这个:

      <input type="text" name"whatever" id="datepickerfield" />
      

      领域:

      $("#datepickerfield").datepicker({
       showOn: 'button',
       buttonImage: 'images/icon-calendar.gif',
       buttonImageOnly: true,
       changeMonth: true,
       changeYear: true,
       showAnim: 'slideDown',
       duration: 'fast'
      });
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-03-16
        • 2018-06-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多