<html lang="en">
<head>
<meta charset="UTF-8">
<title>if条件语句</title>
<script type="text/javascript">
var d = new Date();
var h = d.getHours();
var m = d.getMinutes();
var s = d.getSeconds();
var time =""+h+':'+m+':'+s;
document.write("<b>当前时间是:</b>"+time+'</br>');
if (s<20)
{
document.write("<b>20s之内!</b>");
}
else if (s>=20 && time<40)
{
document.write("<b>小于40s且大约等于20s</b>");
}
else
{
document.write("<b>大于等于40s</b>");
}
</script>
</head>
<body>
</body>
</html> 交作业~
@不二如是
流程图最后一个判断编写错了,应该是大于等于40s rollerpig 发表于 2017-11-14 22:06
@不二如是
流程图最后一个判断编写错了,应该是大于等于40s
已修复·~ {:5_91:} 自己尝试实现,多实践 {:10_266:}
<html>
<head>
<meta charset="utf-8">
<title>鱼C - else if</title>
</head>
<body>
<!-- 题目:当本地时间小于20s时,弹出"20s之内!"。
20s之后弹出"小于40s且大于等于20s" -->
<script type="text/javascript">
var now = new Date();
var time = now.getSeconds();
if(time < 20){
document.write("<b>20s之内!</b>");
}
else if ( time >= 20 && time < 40){
document.write("<b>小于40s且大于等于20s</b>");
}
else {
document.write("<b>大于40s</b>");
}
</script>
</body>
</html> 学习了{:10_333:}
页:
[1]