我想问一下如何将今天的日期显示到禁用的输入日期框?
date.html:
<input id="today" type="date" disabled>
calender.jsp:
<script>document.getElementById('today').value = moment().format('YYYY-MM-DD'); </script>
答案 0 :(得分:1)
我希望这会奏效......
var date = document.getElementById('today');
var day = new Date();
var thisDate = day.getDate();
var thisMonth = day.getMonth()+1;
var thisYear = day.getFullYear();
if(thisDate<10){
thisDate='0'+thisDate;
}
if(thisMonth<10){
thisMonth='0'+thisMonth;
}
date.value = thisYear+'/'+thisDate+'/'+thisMonth;
&#13;
<input id="today" disabled value="21/03/2017">
&#13;