html:
<div id="kinerDatePickerInput" startYear="1950" default-val="1995-1-1">请选择出生年月日</div> <button id="btn">获取</button>
js:
$('#kinerDatePickerInput').kinerDatePicker({
clickMaskHide: false,
showHandler: function(ctx) {
console.log("显示时间选择器:", ctx);
},
hideHandler: function(ctx) {
console.log("隐藏时间选择器:", ctx);
},
changeHandler: function(vals, ctx) {
console.log("时间改变:", vals, ctx);
},
okHandler: function(vals, ctx) {
console.log("确定选择:", vals, ctx);
},
cancelHandler: function(ctx) {
console.log("取消选择:", ctx);
}
});
$('#btn').click(function() {
console.log($('#kinerDatePickerInput').kinerDatePickerVal());
});
可以再实例化的时候指定截止日期,不过目前仅支持截止年份,截止的月份和具体哪一天尚未做处理。
$('#kinerDatePickerInput1').kinerDatePicker({
clickMaskHide: true,
endDate: new Date(2022, 11, 30), //规定截止年份
showHandler: function(ctx) {
console.log("显示时间选择器:", ctx);
},
hideHandler: function(ctx) {
console.log("隐藏时间选择器:", ctx);
},
changeHandler: function(vals, ctx) {
console.log("时间改变:", vals, ctx);
},
okHandler: function(vals, ctx) {
console.log("确定选择:", vals, ctx);
},
cancelHandler: function(ctx) {
console.log("取消选择:", ctx);
}
});