<!DOCTYPE html> <!--[if lt IE 9]> <script type="text/javascript" src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <html> <head> <meta charset="utf-8"> <title>jQuery UI 測試</title> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/hot-sneaks/jquery-ui.css" rel="stylesheet"> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script> <script type="text/javascript" src="../jquery/jquery.ui.datepicker-zh-TW.js"></script> <style> article,aside,figure,figcaption,footer,header,hgroup,menu,nav,section {display:block;} body {font: 62.5% "Trebuchet MS", sans-serif; margin: 50px;} </style> </head> <body> <input id="datepicker1" type="text" /> <button id="button1">週數</button> <div id="msgbox1" title="訊息"></div> <script language="JavaScript"> $(document).ready(function(){ $("#datepicker1").datepicker({showWeek: true}); $("#button1").button(); $("#msgbox1").dialog({autoOpen: false, buttons: {"確定": function() {$(this).dialog("close");}} }); $("#button1").click(function() { var date=$("#datepicker1").datepicker("getDate"); var date_str=$.datepicker.formatDate("yy-mm-dd", date); var date_parsed=$.datepicker.parseDate("yy-mm-dd", date_str); var week=$.datepicker.iso8601Week(date); var msg=date_str + " 是第 " + week + " 週<br>" + date_str + " 之日期物件內容 : " + date_parsed; $("#msgbox1").html(msg); $("#msgbox1").dialog("open"); }); }); </script> </body> </html>