本文說明datepicker 中的setDefaults iso8601Week

其設定參數及一年中的第幾週

一、基本JS/HTML語法

JS:

$.datepicker.setDefaults({

dateFormat : "(yy--mm--dd)"

});

$.datepicker.iso8601Week( $.datepicker.parseDate("yy/mm/dd", "2008/08/08"));

二、基本說明

全局設置日期選擇插件的參數.

$.datepicker.setDefaults( options )

給出一個日期,確實他是一年中的第幾週

$.datepicker.iso8601Week( date )

三、程式內容

<html>
<head>
<title>jquery.datepicker 27</title>
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<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() {
    //27-jQuery datepicker setDefaults iso8601Week
    $("#datepicker").datepicker();
    $(".setDefaultsTest").bind("click", function() {
   $.datepicker.setDefaults({
    dateFormat : "(yy--mm--dd)"
   });
    });
 $(".getiso8601WeekTest").bind("click", function() {
  $("#showDateBox").append("第幾周:"+ $.datepicker.iso8601Week( $.datepicker.parseDate("yy/mm/dd", "2008/08/08") ));
    });
  });
</script>
</head>
<body>
  <div class="datetest">
    <p class="datag">
      Date: <input type="text" id="datepicker" value="">
    </p>
  </div>
  <div>說明:jQuery datepicker Methods setDefaults iso8601Week</div>
  <div>
    <ul>
      <li><a href="javascript:void(0)" class="setDefaultsTest">設定日期格式為(yy--mm--dd)</a></li>
   <li><a href="javascript:void(0)" class="getiso8601WeekTest">取得日期2008/08/08是第幾周</a></li>
    </ul>
  </div>
  <div id="showDateBox"></div>
</body>
</html>
	

四、執行

圖1

五、測試

Date: 

說明:jQuery datepicker Methods setDefaults iso8601Week

相關參考:

其它參考:

jQuery教學目錄

其它文章



arrow
arrow

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