index.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>js网页日期插件</title>
  6. <script type="text/javascript" src="js/laydate.js"></script>
  7. <style type="text/css">
  8. *{margin:0;padding:0;list-style:none;}
  9. html{background-color:#E3E3E3; font-size:14px; color:#000; font-family:'微软雅黑'}
  10. h2{line-height:30px; font-size:20px;}
  11. a,a:hover{ text-decoration:none;}
  12. pre{font-family:'微软雅黑'}
  13. .box{width:970px; padding:10px 20px; background-color:#fff; margin:10px auto;}
  14. .box a{padding-right:20px;}
  15. .demo1,.demo2,.demo3,.demo4,.demo5,.demo6{margin:25px 0;}
  16. h3{margin:10px 0;}
  17. .layinput{height: 22px;line-height: 22px;width: 150px;margin: 0;}
  18. </style>
  19. </head>
  20. <body>
  21. <div class="box">
  22. <div class="demo1">
  23. <h3>演示二(普通模式)</h3>
  24. <input class="laydate-icon" id="demo" value="2014-6-25更新">
  25. </div>
  26. <div class="demo2">
  27. <h3>演示一(日期精确到秒)</h3>
  28. <input placeholder="请输入日期" class="laydate-icon" onClick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
  29. </div>
  30. <div class="demo3">
  31. <h3>演示三(日期范围限制)</h3>
  32. <ul class="inline" id="demo">
  33. 开始日:<input class="laydate-icon" value="2014-6-25更新">
  34. 结束日:<input class="laydate-icon" value="2014-6-25更新">
  35. </ul>
  36. </div>
  37. <div class="demo4">
  38. <h3>演示四(自定义日期格式)</h3>
  39. <div id="test1" class="inline laydate-icon" style="width:150px;"></div>
  40. </div>
  41. <div class="demo5">
  42. <h3>演示五(日期范围限定在昨天到明天)</h3>
  43. <div class="inline laydate-icon" style="width:150px;" id="hello3"></div>
  44. </div>
  45. <div class="demo6">
  46. <h3>演示六(按钮触发日期)</h3>
  47. <input readonly class="layinput" id="hello1">
  48. <div class="laydate-icon " onClick="laydate({elem: '#hello1'});" style="width:10px;display:inline-block;border:none;"></div>
  49. </div>
  50. </div>
  51. <script type="text/javascript">
  52. !function(){
  53. laydate.skin('molv');//切换皮肤,请查看skins下面皮肤库
  54. laydate({elem: '#demo'});//绑定元素
  55. }();
  56. //日期范围限制
  57. var start = {
  58. elem: '#start',
  59. format: 'YYYY-MM-DD',
  60. min: laydate.now(), //设定最小日期为当前日期
  61. max: '2099-06-16', //最大日期
  62. istime: true,
  63. istoday: false,
  64. choose: function(datas){
  65. end.min = datas; //开始日选好后,重置结束日的最小日期
  66. end.start = datas //将结束日的初始值设定为开始日
  67. }
  68. };
  69. var end = {
  70. elem: '#end',
  71. format: 'YYYY-MM-DD',
  72. min: laydate.now(),
  73. max: '2099-06-16',
  74. istime: true,
  75. istoday: false,
  76. choose: function(datas){
  77. start.max = datas; //结束日选好后,充值开始日的最大日期
  78. }
  79. };
  80. laydate(start);
  81. laydate(end);
  82. //自定义日期格式
  83. laydate({
  84. elem: '#test1',
  85. format: 'YYYY年MM月DD日',
  86. festival: true, //显示节日
  87. choose: function(datas){ //选择日期完毕的回调
  88. alert('得到:'+datas);
  89. }
  90. });
  91. //日期范围限定在昨天到明天
  92. laydate({
  93. elem: '#hello3',
  94. min: laydate.now(-1), //-1代表昨天,-2代表前天,以此类推
  95. max: laydate.now(+1) //+1代表明天,+2代表后天,以此类推
  96. });
  97. </script>
  98. </body>
  99. </html>