![](/img/trans.png)
[英]how to get the first date and last date of the month whenever I change the month/year in jquery ui datepicker
[英]How to get year and month of Bootstrap Datepicker as it on change
我是這個日期選擇器的新手,我不知道如何在更改事件changeMonth
和changeYear
上獲取月份和年份字符串。 這是插件的鏈接: https : //github.com/eternicode/bootstrap-datepicker
問題是 onchange 只捕獲從幾個月到幾年的過渡。 我只能獲取所選日期的日期/日期,並且在過渡期間沒有選擇任何內容。
我試圖從 div 中抓取文本,但我總是選擇一個為時已晚。 如何獲取轉換后所選值的月份和年份。
澄清: getYear() 當我們從十年視圖更改后看到所有 12 個月時
getMonth() 當我們看到月視圖后的幾天時
這是我的小提琴: http : //jsfiddle.net/vj3cdzbc/2/
獲取月份:
$("#datepicker").datepicker().on('changeMonth', function(e){
var currMonth = new Date(e.date).getMonth() + 1;
});
獲取年份
$("#datepicker").datepicker().on('changeYear', function(e){
var currYear = String(e.date).split(" ")[3];
});
獲取月份和年份
$("#datepicker").datepicker().on('changeDate', function (e) {
var pickedMonth = new Date(e.date).getMonth() + 1;
var pickedYear = new Date(e.date).getFullYear();
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.