设置date输入框的默认值为当前时间

            //设置日期默认值为当天
            var nowDate=new Date();     
            var nowMonth=nowDate.getMonth()+1;   //月份和日期若为小于10的数要做处理
            var nowDay=nowDate.getDate(); 
            if((nowDate.getMonth()+1)<10){    
                nowMonth="0"+nowMonth; 
            }
            if(nowDate.getDate()<10){
                nowDay='0'+nowDay;
            }
            var dateVal=nowDate.getFullYear()+"-"+nowMonth+"-"+nowDay;    //显示格式:2018/07/14
            $('.date').val(dateVal);

猜你喜欢

转载自blog.csdn.net/Lyj1010/article/details/81047318