日曆控制元件input框預設顯示當日日期
阿新 • • 發佈:2019-02-03
圖片.png
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
<title></title>
</head>
<body>
<input type="text" name="alertDateQuery" id ="aDate">
</body>
<script type="text/javascript">
var mydateInput = document.getElementById("aDate");
var date = new Date();
var dateString = date.getFullYear() + "/" + (date.getMonth() + 1) + "/" + date.getDate();
mydateInput.value = dateString;
</script>
</html>