EasyUI篇の日期控件

页面代码:

1 <input type="text" id='astartTime' class="easyui-datebox" style="width: 150px;" />
View Code

JS代码:

 1 <script type="text/javascript">
 2         $(function () {
 3             $("#astartTime").datebox({
 4                 onSelect: function (date) {   //选择日期
 5                     $("#astartTime ").val(date);
 6                     alert(date.getFullYear() + "年" + (date.getMonth() + 1) + "月" + date.getDate() + "日");
 7                 }
 8             });
 9         })
10         window.onload = function () {
11             $('#astartTime').datebox('setValue', formatterDate(new Date()));//设置日期初始日期为当前日期
12         }
13         formatterDate = function (date) {
14             var day = date.getDate() > 9 ? date.getDate() : "0" + date.getDate();
15             var month = (date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : "0" + (date.getMonth() + 1);
16             return date.getFullYear() + '-' + month + '-' + day;
17         };
18     </script>
View Code

运行效果图:

posted @ 2015-11-14 11:23  熊大大-  阅读(255)  评论(0编辑  收藏  举报