<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<input id="y" type="text" placeholder="年" /> <input id="m" type="text" placeholder="月" />
<nput id="d" type="text" placeholder="日" /> <br /> <input type="button" id="btn" value="计算星期几" /> <input type="text"
id="w" placeholder="星期几">
<script>
var y = document.getElementById('y');
var m = document.getElementById('m');
var d = document.getElementById('d');
var w = document.getElementById('w');
var btn = document.getElementById('btn');
btn.onclick = function () {
var a = '';
a = y.value + '/' + m.value + '/' + d.value;
var date = new Date(a);
var week = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
w.value = week[date.getDay()];
}
</script>
</body>
</script>
</body>
</html>