本文說明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 datepicker 預設基本樣式
- jQuery datepicker 月曆樣式種類
- jQuery datepicker 加入button效果 showOn buttonText
- jQuery datepicker 加入月曆icon小圖buttonImage buttonImageOnly
- jQuery datepicker 設定動畫效果 showAnim showOptions duration
- jQuery datepicker 設定動畫效果樣式
- jQuery datepicker 顯示及格式相關 appendText altField altFormat autoSize dateFormat constrainInput
- jQuery datepicker 日期解析及格式相關方法 parseDate formatDate
- jQuery datepicker 月曆框下拉式年月份 changeMonth changeYear showMonthAfterYear
- jQuery datepicker 月曆框功能鍵 showButtonPanel closeTextType currentText nextText prevText navigationAsDateFormat
- jQuery datepicker 設定月曆顯示文字 dayNames dayNamesShort dayNamesMin monthNames monthNamesShort
- jQuery datepicker 設定多個月曆框 numberOfMonths showCurrentAtPos
其它參考:
jQuery教學目錄
其它文章

沒有留言:
張貼留言