【问题标题】:Is there anyway to make a jQuery UI Datepicker unclickable?有没有办法让 jQuery UI Datepicker 无法点击?
【发布时间】:2011-04-05 10:17:18
【问题描述】:

有没有办法让jQuery UI Datepicker 不可点击,这样它实际上只是显示一个日期?我试过了

$("#calendar").datepicker({ 
    disabled: true,
    altField: '#note_date',
    maxDate: 0
});

但它没有用。感谢阅读。

【问题讨论】:

    标签: javascript jquery jquery-ui datepicker uidatepicker


    【解决方案1】:

    这样的?

    示例: http://jsfiddle.net/Ay6Nv/

    $('#calendar').datepicker({
        beforeShowDay: function(date) {
            return [new Date(this.value).getDate() == date.getDate()];
        }
    });​
    

    【讨论】:

    • 您仍然可以使用此实现更改月份。如果您将最后一行更改为返回 [new Date(this.value) == date];您无法更改日期,但今天的 td 也会丢失。
    【解决方案2】:

    为什么不在输入中添加 readonly 属性,如下所示:

    <input type='text' value='24/01/2019' readonly="readonly" />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-12
      • 1970-01-01
      • 2021-11-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多