JavaScript else If 语句用法 【每日一段代码44】

<html>
<head>
<title> else if </title>
</head>
<body>
<script type="text/javascript">
var d = new Date();
var t = d.getHours();
if (t>=6 && t<12)
{
document.write("上午好");
}
else if (t>=12 && t<18)
{
document.write("下午好");
}
else
{
document.write("晚上好");
}
</script>

<p>本例演示 if..else if...else 语句。</p>
</body>
</html>

原文地址:https://www.cnblogs.com/naokr/p/2389582.html