date类型的input框设置默认日期

<input type="date" name="date" id="show_date">

<script>
     $(function(){
         var time = new Date()
         var day = ('0' + time.getDate()).slice(-2)
         var month = ('0' + (time.getMonth() + 1)).slice(-2)
         var today = time.getFullYear() + '-' + month + '-' + day
         $('#show_date').val(today) 
     })
 script>

你可能感兴趣的:(web前端)