close

本文說明datepicker Options 中的 showOtherMonths selectOtherMonths stepMonths isRTL gotoCurrent

其效果會是顯示月曆框有效果

一、基本JS/HTML語法

JS:

$("#datepicker").datepicker({

      showOtherMonths : true,

     selectOtherMonths :true,

      stepMonths : 1,

     isRTL:true,

      showButtonPanel : true,

     currentText:"gotodate",

      gotoCurrent:true

    });

二、基本說明

showOtherMonths : true

default = false

顯示上個月日期及下個月日期 ,但是不可選的

selectOtherMonths :true

default = false

設定上個月日期 及下個月日期為可選的,配合showOtherMonths

stepMonths : 1

default = 1

按上/下月時,一次跳幾個月

isRTL:true

default = false

如果設置為true,則所有文字是從右自左。

gotoCurrent:true

default = false

如果設置為true,則點擊當天按鈕時,將移至當前已選中的日期,而不是今天。

配合: showButtonPanel

參考:

三、程式內容

<html>
<head>
<title>jquery.datepicker 14</title>
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script>
  $(function() {
    $("#datepicker").datepicker({
      //顯示上個月日期及下個月日期 ,但是不可選的
      //default = false
      showOtherMonths : true,
    //設定上個月日期 及下個月日期為可選的,配合showOtherMonths
   //default = false
   selectOtherMonths :true,
      //按上/下月時,一次跳幾個月
      //default = 1
      stepMonths : 1,
   // 如果設置為true,則所有文字是從右自左。
   isRTL:true,
   //設定面板顯示相關按鈕,會有二個按鈕,取得今天日期、關閉
      showButtonPanel : true,
   currentText:"gotodate",
   //如果設置為true,則點擊當天按鈕時,將移至當前已選中的日期,而不是今天。
      gotoCurrent:true
    });
  });
</script>
</head>
<body>
  <div class="datetest">
    <p class="datag">
      Date: <input type="text" id="datepicker" value="">
    </p>
  </div>
  <div>說明:設定月曆框上下月按鈕效果</div>
</body>
</html>
	

四、執行

圖1

五、測試

Date: 

說明:設定月曆框上下月按鈕效果

相關參考:

其它參考:

jQuery教學目錄

其它文章



arrow
arrow
    創作者介紹
    創作者 PG Levin Li 的頭像
    PG Levin Li

    程式開發學習之路

    PG Levin Li 發表在 痞客邦 留言(0) 人氣()