Javascript examples for DOM:Document querySelector
Get DOM element by ID selector
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {/*from w w w . ja v a2 s . c om*/ (function () { var date = new Date().toISOString().substring(0, 10), field = document.querySelector('#date'); field.value = date; console.log(field.value); })(); }); </script> </head> <body> <input id="date" type="date" value="2019-11-11"> </body> </html>