【问题标题】:Get dateinput max and min date获取 dateinput 最大和最小日期
【发布时间】:2014-06-05 08:06:24
【问题描述】:

我使用来自jQuery TOOLS UI librarydateinput(),并设置了最小和最大日期。

但是,我想在设置这些值后获取它们。如何做到这一点?

【问题讨论】:

  • dateinput 不是标准插件。您能否详细说明您正在使用什么。
  • 有一个叫做 dateinput() 的日期选择器,就像 jquery 中的 datepicker() 一样,更多信息见jquerytools.org/demos/dateinput/customize.html
  • 网站和 GitHub 上的文档严重缺乏......我建议在浏览器控制台中检查 jQuery 对象并尝试在那里找到它。
  • 有一个名为getConf()的方法,但我不知道如何使用它。检查这个jquerytools.org/documentation/dateinput

标签: javascript jquery jquery-tools


【解决方案1】:

你可以试试这个:

$(":date").dateinput({
    format: 'dddd dd, mmmm yyyy', // the format displayed for the user
    selectors: true, // whether month/year dropdowns are shown
    min: -100, // min selectable day (100 days backwards)
    max: 100, // max selectable day (100 days onwards)
    offset: [10, 20], // tweak the position of the calendar
    speed: 'fast', // calendar reveal speed
    firstDay: 1, // which day starts a week. 0 = sunday, 1 = monday etc..
    change: function (a) {
        console.log($(this)[0].getConf().min);//min value
        console.log($(this)[0].getConf().max);//max value
    }
});

HTML:

<input type="date" name="date1" value="Today" />
<input type="date" name="date2" value="10 days from now" min="2010-03-01" max="2012-01-01" class="one" />
<input type="date" name="date3" value="15" min="-25" max="25" data-value="15" />

演示:http://jsfiddle.net/GCu2D/159/

除了change 功能,它还有onShowonHide 以防万一你想在以后或节目中使用min max。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-13
    • 1970-01-01
    • 2012-07-16
    • 2021-12-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多