How to set input type date's default value to today?

后端 未结 30 3288
刺人心
刺人心 2020-11-22 14:00

The HTML5 input types are great, Opera\'s new built-in date picker is a breeze, and Chrome has at least supported the new input type with a spin-wheel implementation.

<
30条回答
  •  一个人的身影
    2020-11-22 14:35

    Javascript

    document.getElementById('date-field').value = new Date().toISOString().slice(0, 10);
    

    Jquery

    $('#date-field').val(new Date().toISOString().slice(0, 10));
    

    Another Option

    If you want to customize the date, month and year just do sum or sub as your wish

提交回复
热议问题