1. 程式人生 > >關於datepicker只顯示年、月、日的設定

關於datepicker只顯示年、月、日的設定

然後,直接上程式碼。如下是隻顯示月的sample code:

$("#datepicker").datepicker({
          language: "zh-CN",
          todayHighlight: true,
          format: 'yyyy-mm',
          autoclose: true,
          startView: 'months',
          maxViewMode:'months',
          minViewMode:'months'
});

問題的關鍵在三個引數的設定:startView, maxViewMode, minViewMode
The view that the datepicker should show when it is opened. Accepts:
0 or “days” or “month”,
1 or “months” or “year”,
2 or “years” or “decade”,
3 or “decades” or “century”,
4 or “centuries” or “millenium”.