我正在使用 jQuery TOOLS UI library 中的 dateinput()
,我设置了最小和最大日期。
但是,我想在设置这些值后获取它们。如何才能实现这一目标?
最佳答案
你可以试试这个:
$(":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
功能外,它还有onShow
和onHide
以防万一您想稍后或在显示时使用min max。
关于javascript - 获取日期输入最大和最小日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24054872/