Set the default value for the date type input to the current time

<input type="date" id="date" placeholder="请选择日期"/>
 $(document).ready(function () {
        var date= new Date();
        var day = ("0" + date.getDate()).slice(-2);
        var month = ("0" + (date.getMonth() + 1)).slice(-2);
        var today= date.getFullYear() + "-" + (month) + "-" + (day);
        $('#date').val(today);
  })

Guess you like

Origin blog.csdn.net/qq_41588568/article/details/109000915