jquery-date
Advanced tools
+32
-1
@@ -83,5 +83,15 @@ <!DOCTYPE html> | ||
| <button type="button" id="date6" data-options="{'type':'YYYY-MM-DD','beginYear':2010,'endYear':2088,'location':'before'}" style="width:170px;height:25px;vertical-align: middle;text-align: left;"></button> | ||
| <hr> | ||
| 自定义日期格式(只展示月和天) | ||
| <br> | ||
| <button type="button" id="date9" data-options="{'type':'YYYY-MM-DD','beginYear':2010,'endYear':2088,'location':'before','callback':'setDate.format'}" style="width:170px;height:25px;vertical-align: middle;text-align: left;"></button> | ||
| <br> | ||
| <hr> | ||
| 日期判断,阻止插件运行(结束时间要大于开始时间) | ||
| <br> | ||
| <button type="button" id="date10" data-options="{'type':'YYYY-MM-DD','beginYear':2010,'endYear':2088,'location':'before'}" style="width:170px;height:25px;vertical-align: middle;text-align: left;">2018-08-01</button> | ||
| <button type="button" id="date11" data-options="{'type':'YYYY-MM-DD','beginYear':2010,'endYear':2088,'location':'before','callback':'setDate.checkDate'}" style="width:170px;height:25px;vertical-align: middle;text-align: left;">结束时间</button> | ||
| <br> | ||
| <br> | ||
| <br> | ||
| <script src="../src/jquery-1.11.3.min.js"></script> | ||
@@ -97,5 +107,26 @@ <script src="../jquery.date.js"></script> | ||
| $.date('#date7'); | ||
| $.date('#date8'); | ||
| $.date('#date8'); | ||
| /*注意对象或函数必须是全局的,callback只接受object.function或function两种,当前的jquery版本功能不是太完善, | ||
| 欢迎关注后续的新版本rolldate(给个star吧^_^),https://github.com/weijhfly/rolldate | ||
| */ | ||
| $.date('#date9'); | ||
| var setDate = { | ||
| format:function(date){ | ||
| return date.substr(date.indexOf('-')+1); | ||
| }, | ||
| checkDate:function(date){ | ||
| var d = $('#date10').text(), | ||
| d1 = new Date(d), | ||
| d2 = new Date(date); | ||
| if(d2 < d1){ | ||
| alert('结束时间不能小于开始时间') | ||
| return false; | ||
| } | ||
| } | ||
| } | ||
| $.date('#date10'); | ||
| $.date('#date11'); | ||
| </script> | ||
| </body> | ||
| </html> |
+18
-2
| /*! | ||
| * jquery.date.js v1.4.2 | ||
| * jquery.date.js v1.4.3 | ||
| * By 雾空 https://github.com/weijhfly/jqueryDatePlugin | ||
@@ -58,3 +58,4 @@ * Date:2017/1/24 | ||
| limitTime:false,//限制选择时间 today 今天之前的时间不可选 tomorrow 明天之前的不可选 | ||
| location:null //before 跳转至之前选择的时间,如果为空则跳转至当前时间 | ||
| location:null, //before 跳转至之前选择的时间,如果为空则跳转至当前时间 | ||
| callback:null//回调函数 | ||
| }; | ||
@@ -450,2 +451,17 @@ //dom渲染 | ||
| } | ||
| // 回调函数 | ||
| var fun = opt.callback; | ||
| if(fun){ | ||
| if(fun.indexOf('.') == -1){ | ||
| var flag = window[fun](str); | ||
| }else{ | ||
| var arr = fun.split('.'), | ||
| flag = window[arr[0]][arr[1]](str); | ||
| } | ||
| if(flag == false){ | ||
| return false; | ||
| }else if(flag){ | ||
| str = flag; | ||
| } | ||
| } | ||
| //赋值 | ||
@@ -452,0 +468,0 @@ if(that.get(0).tagName == 'INPUT'){ |
+1
-1
| { | ||
| "name": "jquery-date", | ||
| "version": "1.4.2", | ||
| "version": "1.4.3", | ||
| "description": "jquery移动端时间插件", | ||
@@ -5,0 +5,0 @@ "main": "jquery.date.js", |
+1
-1
@@ -6,3 +6,3 @@ # jquery-date [](https://www.npmjs.com/package/jquery-date) | ||
| 下一版本计划 | ||
| 下一版本计划 ([rolldate--传送门](https://github.com/weijhfly/rolldate "rolldate")) | ||
| ----------------------------------- | ||
@@ -9,0 +9,0 @@ - 不依赖jquery。 |
+3
-0
@@ -0,1 +1,4 @@ | ||
| ##2018/8/1 | ||
| 1,支持回调函数。 | ||
| ##2018/4/12 | ||
@@ -2,0 +5,0 @@ 1,增加时分秒、时分格式。 |
127731
1.7%890
1.83%