为什么getday()不能输出正确的星期

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<html>
<body>
<p>点击这个按钮,获得基于时间的问候。</p>
<button onclick="myFunction()">点击这里</button>
<script>
function myFunction()
{
var x="";
var time=new Date().getDay();
if (time=0)
  { x="Good morning"; }
else if (time=1)
  {  x="Good day";  }
else
  { x="Good evening";  }
alert(x);

}
</script>
</body>
</html>

Hakumatsu
浏览 1791回答 4
4回答

__innocence

if里面,判断是否相等用== 而不是=,=是赋值
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript