javaScript输入某年某月某日弹出那天是星期几
展开全部
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script type="text/javascript">
function test(id){
var NewArray = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六")
var obj = document.getElementById(id);
KingVal = obj.value;
DateYear = parseInt(KingVal.split("-")[0]);
DateMonth = parseInt(KingVal.split("-")[1]);
DateDay = parseInt(KingVal.split("-")[2]);
var NewDate = new Date(DateYear,DateMonth-1,DateDay);
var NewWeek = NewDate.getDay();
alert(NewArray[NewWeek]);
}
</script>
</head>
<body>
<input type="text" id="aa"><input type="button" value="提交" onClick="test('aa')">
</body>
</html>
时间太急,有待改进,但是以上不会出错,望采纳!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询