index.html 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>日期时间选择器:datetimepicker</title>
  6. <meta name="keywords" content="datetimepicker, jquery插件" />
  7. <meta name="description" content="Helloweba演示平台,演示XHTML、CSS、jquery、PHP案例和示例" />
  8. <link rel="stylesheet" type="text/css" href="../css/main.css" />
  9. <link rel="stylesheet" type="text/css" href="css/jquery-ui.css" />
  10. <style type="text/css">
  11. a{color:#007bc4/*#424242*/; text-decoration:none;}
  12. a:hover{text-decoration:underline}
  13. ol,ul{list-style:none}
  14. body{height:100%; font:12px/18px Tahoma, Helvetica, Arial, Verdana, "\5b8b\4f53", sans-serif; color:#51555C;}
  15. img{border:none}
  16. .demo{width:500px; margin:20px auto}
  17. .demo h4{height:32px; line-height:32px; font-size:14px}
  18. .demo h4 span{font-weight:500; font-size:12px}
  19. .demo p{line-height:28px;}
  20. input{width:200px; height:20px; line-height:20px; padding:2px; border:1px solid #d3d3d3}
  21. pre{padding:6px 0 0 0; color:#666; line-height:20px; background:#f7f7f7}
  22. .ui-timepicker-div .ui-widget-header { margin-bottom: 8px;}
  23. .ui-timepicker-div dl { text-align: left; }
  24. .ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }
  25. .ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
  26. .ui-timepicker-div td { font-size: 90%; }
  27. .ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
  28. .ui_tpicker_hour_label,.ui_tpicker_minute_label,.ui_tpicker_second_label,.ui_tpicker_millisec_label,.ui_tpicker_time_label{padding-left:20px}
  29. </style>
  30. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  31. <script type="text/javascript" src="js/jquery-ui.js"></script>
  32. <script type="text/javascript" src="js/jquery-ui-slide.min.js"></script>
  33. <script type="text/javascript" src="js/jquery-ui-timepicker-addon.js"></script>
  34. <script type="text/javascript">
  35. $(function(){
  36. $('#example_1').datetimepicker();
  37. $('#example_2').timepicker({});
  38. $('#example_3').datetimepicker({
  39. showSecond: true,
  40. showMillisec: true,
  41. timeFormat: 'hh:mm:ss:l'
  42. });
  43. $('#example_4').timepicker({
  44. ampm: true,
  45. hourMin: 8,
  46. hourMax: 16
  47. });
  48. $('#example_5').datetimepicker({
  49. hour: 13,
  50. minute: 15
  51. });
  52. $('#example_6').datetimepicker({
  53. numberOfMonths: 2,
  54. minDate: 0,
  55. maxDate: 30
  56. });
  57. $('#example_7').timepicker({
  58. hourGrid: 4,
  59. minuteGrid: 10
  60. });
  61. var ex8 = $('#example_8');
  62. ex8.datetimepicker();
  63. $('#example_8_set_btn').click(function(){
  64. ex8.datetimepicker('setDate', (new Date()) );
  65. });
  66. $('#example_8_get_btn').click(function(){
  67. alert(ex8.datetimepicker('getDate'));
  68. });
  69. });
  70. </script>
  71. </head>
  72. <body>
  73. <div id="header">
  74. <div id="logo"><h1><a href="http://www.helloweba.com" title="返回helloweba首页">helloweba</a></h1></div>
  75. </div>
  76. <div id="main">
  77. <h2 class="top_title"><a href="http://www.helloweba.com/view-blog-169.html">日期时间选择器:datetimepicker</a></h2>
  78. <div class="demo">
  79. <h4>1、默认:</h4>
  80. <p><input type="text" id="example_1" /></p>
  81. <pre>
  82. $('#example_1').datetimepicker();
  83. </pre>
  84. </div>
  85. <div class="demo">
  86. <h4>2、只选择时间:</h4>
  87. <p><input type="text" id="example_2" /></p>
  88. <pre>
  89. $('#example_2').timepicker();
  90. </pre>
  91. </div>
  92. <div class="demo">
  93. <h4>3、显示时分秒毫秒格式:</h4>
  94. <p><input type="text" id="example_3" /></p>
  95. <pre>
  96. $('#example_3').datetimepicker({
  97. showSecond: true,
  98. showMillisec: true,
  99. timeFormat: 'hh:mm:ss:l'
  100. });
  101. </pre>
  102. </div>
  103. <div class="demo">
  104. <h4>4、设置时间可选范围:</h4>
  105. <p><input type="text" id="example_4" /></p>
  106. <pre>
  107. $('#example_4').timepicker({
  108. ampm: true,
  109. hourMin: 8,
  110. hourMax: 16
  111. });
  112. </pre>
  113. </div>
  114. <div class="demo">
  115. <h4>5、默认时间:</h4>
  116. <p><input type="text" id="example_5" /></p>
  117. <pre>
  118. $('#example_5').datetimepicker({
  119. hour: 13,
  120. minute: 15
  121. });
  122. </pre>
  123. </div>
  124. <div class="demo">
  125. <h4>6、显示多月并设置可选日期范围:</h4>
  126. <p><input type="text" id="example_6" /></p>
  127. <pre>
  128. $('#example_6').datetimepicker({
  129. numberOfMonths: 2,
  130. minDate: 0,
  131. maxDate: 30
  132. });
  133. </pre>
  134. </div>
  135. <div class="demo">
  136. <h4>7、显示时间标尺:</h4>
  137. <p><input type="text" id="example_7" /></p>
  138. <pre>
  139. $('#example_7').timepicker({
  140. hourGrid: 4,
  141. minuteGrid: 10
  142. });
  143. </pre>
  144. </div>
  145. <div class="demo">
  146. <h4>8、获取和设置时间:</h4>
  147. <p><input type="text" id="example_8" />
  148. <button id="example_8_set_btn">Set Datetime</button>
  149. <button id="example_8_get_btn">Get Datetime</button>
  150. <pre>
  151. var ex8 = $('#example_8');
  152. ex8.datetimepicker();
  153. $('#example_8_set_btn').click(function(){
  154. ex8.datetimepicker('setDate', (new Date()) );
  155. });
  156. $('#example_8_get_btn').click(function(){
  157. alert(ex8.datetimepicker('getDate'));
  158. });
  159. </pre>
  160. </div>
  161. <br/>
  162. </div>
  163. <div id="footer">
  164. <p>Powered by helloweba.com 允许转载、修改和使用本站的DEMO,但请注明出处:<a href="http://www.helloweba.com">www.helloweba.com</a></p>
  165. </div>
  166. <p id="stat"><script type="text/javascript" src="http://js.tongji.linezing.com/1870888/tongji.js"></script></p>
  167. </body>
  168. </html>