MinsoftK

test change tag style using Loop and array

...@@ -16,21 +16,7 @@ ...@@ -16,21 +16,7 @@
16 16
17 <!--refactoring and conditional statement --> 17 <!--refactoring and conditional statement -->
18 18
19 - <input id="night_day" type="button" value="night" onclick="
20 - if(document.querySelector('#night_day').value==='night')
21 - {
22 19
23 - var target=document.querySelector('body');
24 -
25 - target.style.backgroundColor= 'black';
26 - target.style.color= 'white';
27 - document.querySelector('#night_day').value= 'day';
28 - }else{
29 - target.style.backgroundColor= 'white';
30 - target.style.color= 'black';
31 - document.querySelector('#night_day').value= 'night';
32 - }
33 - ">
34 <!-- about this grammer 20 <!-- about this grammer
35 21
36 <input type="button" value="night" onclick=" 22 <input type="button" value="night" onclick="
...@@ -74,7 +60,7 @@ ...@@ -74,7 +60,7 @@
74 60
75 61
76 62
77 -<!--Loop & Array --> 63 +<!--Loop & Array
78 <script> 64 <script>
79 var cowokers=["minsung","leezche","minsoft","sdy"]; 65 var cowokers=["minsung","leezche","minsoft","sdy"];
80 </script> 66 </script>
...@@ -86,7 +72,62 @@ ...@@ -86,7 +72,62 @@
86 i+=1; 72 i+=1;
87 } 73 }
88 </script> 74 </script>
75 +-->
76 +
77 +<!-- Loop apply
78 +var alist=document.querySelectorAll('a');
79 +var i =0;
80 +while(i<alist.length){
81 +console.log(alist[i]);
82 +i+=1;
83 +}
84 +-->
85 +
86 +<!-- button 1 usage array and Loop for chage style -->
87 +<input id="night_day" type="button" value="night" onclick="
88 +var target=document.querySelector('body');
89 +if(document.querySelector('#night_day').value==='night')
90 +{
91 + target.style.backgroundColor= 'black';
92 + target.style.color= 'white';
93 + document.querySelector('#night_day').value= 'day';
94 +
95 + var alist=document.querySelectorAll('a');
96 + var i =0;
97 + while(i<alist.length)
98 + {
99 + alist[i].style.color='powderblue';
100 + i+=1;
101 + }
102 +}else{
103 + target.style.backgroundColor= 'white';
104 + target.style.color= 'black';
105 + document.querySelector('#night_day').value= 'night';
106 +
107 + var alist=document.querySelectorAll('a');
108 + var i =0;
109 + while(i<alist.length)
110 + {
111 + alist[i].style.color='blue';
112 + i+=1;
113 + }
114 +}
115 +">
89 116
117 +<!-- button2 -->
118 + <input id="night_day" type="button" value="night" onclick="
119 + var target=document.querySelector('body');
120 + if(this.value==='night')
121 + {
122 + target.style.backgroundColor= 'black';
123 + target.style.color= 'white';
124 + this.value= 'day';
125 + }else{
126 + target.style.backgroundColor= 'white';
127 + target.style.color= 'black';
128 + this.value= 'night';
129 + }
130 + ">
90 131
91 <div id="grid"> 132 <div id="grid">
92 <ol> 133 <ol>
......