标签:
Good morning
<!DOCTYPE html>
<html>
<meta http-equiv="Content-Type" content="text/html charset=utf-8"/>
<head>
<title></title>
</head>
<body>
<p>如果时间早于7:00,会问候“Good Day”.</p>
<button onclick="myFunction()">点击这里</button>
<p id = "demo"></p>
<script type="text/javascript">
function myFunction()
{
var x = "";
var time = new Date().getHours();
/*if(time < 7)
{
x = "Good Day";
}
else
{
x = "Your are a lazy guy ";
}
document.getElementById("demo").innerHTML=x;
*/
if(time < 10)
{
x = "Good morning";
}
else if(time < 20)
{
x = "Good Day";
}
else
{
x = "Good evening";
}
document.write(x);
}
</script>
</body>
</html><!DOCTYPE html>
<html>
<meta http-equiv="Content-Type" content="text/html charset=utf-8"/>
<head>
<title></title>
</head>
<body>
<p>如果时间早于7:00,会问候“Good Day”.</p>
<button onclick="myFunction()">点击这里</button>
<p id = "demo"></p>
<script type="text/javascript">
function myFunction()
{
var x = "";
var time = new Date().getHours();
/*if(time < 7)
{
x = "Good Day";
}
else
{
x = "Your are a lazy guy ";
}
document.getElementById("demo").innerHTML=x;
*/
if(time < 10)
{
x = "Good morning";
}
else if(time < 20)
{
x = "Good Day";
}
else
{
x = "Good evening";
}
document.write(x);
}
</script>
</body>
</html>
标签:
原文地址:http://blog.csdn.net/u012701023/article/details/46313089