search

Home  >  Q&A  >  body text

javascript - Can the default value of type="date" be changed to today's date?

Use h5 input type="date" to write date selection, but you want the default value to be displayed as the current year, month and day. How to achieve this?

Additional:
I have obtained the date of the day through js, and can also assign it to the input of type="date", but the current date is not displayed on the interface. Question: How can I display the current date by default on the interface?

仅有的幸福仅有的幸福2797 days ago695

reply all(2)I'll reply

  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-16 13:44:59

    It seems impossible to achieve using pure html.

    It’s very simple to use js: get the current time and then pass it in to the form.

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-16 13:44:59

    var i='2017-04-20'
    $('input[type="date"]').val(i)

    reply
    0
  • Cancelreply