jquery easyui datebox 时间控件默认显示当前日期的实现方法

在jsp页面添加如下代码,其中startTime为<input >中id值

 <script>
//得到当前日期
formatterDate = function(date) {
var day = date.getDate() > 9 ? date.getDate() : "0" + date.getDate();
var month = (date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : "0"
+ (date.getMonth() + 1);
return date.getFullYear() + '-' + month + '-' + day;
};

window.onload = function () { 
$('#startTime').datebox('setValue', formatterDate(new Date()));
}
    </script>

猜你喜欢

转载自blog.csdn.net/xianrenyingzi/article/details/19990557