실습문제 7-3

WEB/TRAINNING 2017. 11. 21. 10:57 |

3. 예제 7-6을 수정하여 웹 페이지를 접속할 때 오전이면 배경색을 lightskyblue로, 오후이면 orange로 출력되게 하라.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!DOCTYPE html>
<html>
<head>
<title>방문 시간에 따라 변하는 배경색</title></head>
<body>
<h3>오전이면 lightSkyblue, 오후이면 orange 배경</h3>
<hr>
<script>
var current = new Date(); // 현재 시간 값을 가진 Date 객체 생성
if(current.getHours() < 12)
    document.body.style.backgroundColor = "lightskyblue";
else
    document.body.style.backgroundColor = "orange";
 
document.write("현재 시간 : ");
document.write(current.getHours(), "시,");
document.write(current.getMinutes(), "분,");
document.write(current.getSeconds(), "초<br>");
</script>
</body>
</html>
cs


'WEB > TRAINNING' 카테고리의 다른 글

실습문제 7-5  (0) 2017.11.21
실습문제 7-4  (0) 2017.11.21
실습문제 7-2  (0) 2017.11.21
실습문제 7-1  (0) 2017.11.21
실습문제 6-7  (0) 2017.11.18
Posted by 너래쟁이
: