-
Notifications
You must be signed in to change notification settings - Fork 0
/
for_2.html
37 lines (37 loc) · 926 Bytes
/
for_2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!--for문1-100중
5의배수일떄 빨간색/
7의배수일때 초록색/
5의배수&&7의배수 아쿠아색-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>for문1-100중 조건 색으로 표현</title>
<style>
.green{
color:green;
}
.red{
color:red;
}
.aqua{
color:aqua;
}
</style>
</head>
<body>
<script>
for(var i=1; i<=100; i++){
if(i%5==0 && i%7!=0){
document.write('<p class="red">'+i+'</p>');
}
else if(i%7==0 && i%5!=0){
document.write('<p class="green">'+i+'</p>');
}else if(i%5==0 && i%7==0){
document.write('<p class="aqua">'+i+'</p>');
}
}
</script>
</body>
</html>