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