0

我已經使用jquery-ui multidate選擇器創建了一個內聯日曆。我想,每當我改變月/年(通過點擊一個/下一個按鈕或從列表中選擇某月/年)如何獲取每月的第一個日期和最後一個日期,只要我在jQuery UI中更改月份/年份datepicker

<!doctype html> 
<html lang="en"> 
    <head> 
     <meta charset="utf-8"> 
     <title>jQuery UI Datepicker functionality</title> 
     <link href="http://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet"> 
     <link rel="stylesheet prefetch" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/smoothness/jquery-ui.css"> 

    <script src="http://code.jquery.com/jquery-2.1.4.js"></script> 
    <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script> 
    <script type="text/javascript" src="js/jquery-ui.multidatespicker.js"></script> 


    <script> 
    $(function() { 

     var today = new Date(); 
     var yesterday = (new Date()).setDate(today.getDate()-1); 
     var tomorrow = (new Date()).setDate(today.getDate()+1); 
     var dayAfttomorrow = (new Date()).setDate(today.getDate()+2); 
     var dayDayAfttomorrow = (new Date()).setDate(today.getDate()+3); 
     var dates = [yesterday, today, tomorrow, dayAfttomorrow, dayDayAfttomorrow]; 


     $('#calendar').multiDatesPicker({ 
      changeYear: true, 
      changeMonth: true, 
      disabled: false, 
      addDates: dates, 
      onSelect: function() { 
       var date = $(this).datepicker('getDate'); 
       $('#calendar').multiDatesPicker('resetDates').multiDatesPicker('addDates', [date]); 
      }, 
      onChangeMonthYear: function(){ 
       // alert("Hii, I'm here"); 
      } 
     }); 

    }); 

    </script> 
    <style type="text/css"> 
    .ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight { 
    border: 1px solid #d3d3d3 !important; 
    background: #3B8CC5 !important; 
    } 
    .ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { 
    border: 1px solid #d3d3d3 !important; 
    } 
    .ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { 
    border: none !important; 
    } 
    /*.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { 
    background: green; 
    }*/ 
    </style> 


</head> 
    <body> 
     <!-- HTML --> 
     <div id="calendar"></div> 
    </body> 
</html> 

回答

0

嘗試JavaScript函數here每月的第一個和最後日期。我希望你可以用你的代碼在

之下幾乎沒有什麼變化
onChangeMonthYear: function(){ 
      // alert("Hii, I'm here"); 
} 
相關問題