MinsoftK

test change tag style using Loop and array

......@@ -16,21 +16,7 @@
<!--refactoring and conditional statement -->
<input id="night_day" type="button" value="night" onclick="
if(document.querySelector('#night_day').value==='night')
{
var target=document.querySelector('body');
target.style.backgroundColor= 'black';
target.style.color= 'white';
document.querySelector('#night_day').value= 'day';
}else{
target.style.backgroundColor= 'white';
target.style.color= 'black';
document.querySelector('#night_day').value= 'night';
}
">
<!-- about this grammer
<input type="button" value="night" onclick="
......@@ -74,7 +60,7 @@
<!--Loop & Array -->
<!--Loop & Array
<script>
var cowokers=["minsung","leezche","minsoft","sdy"];
</script>
......@@ -86,7 +72,62 @@
i+=1;
}
</script>
-->
<!-- Loop apply
var alist=document.querySelectorAll('a');
var i =0;
while(i<alist.length){
console.log(alist[i]);
i+=1;
}
-->
<!-- button 1 usage array and Loop for chage style -->
<input id="night_day" type="button" value="night" onclick="
var target=document.querySelector('body');
if(document.querySelector('#night_day').value==='night')
{
target.style.backgroundColor= 'black';
target.style.color= 'white';
document.querySelector('#night_day').value= 'day';
var alist=document.querySelectorAll('a');
var i =0;
while(i<alist.length)
{
alist[i].style.color='powderblue';
i+=1;
}
}else{
target.style.backgroundColor= 'white';
target.style.color= 'black';
document.querySelector('#night_day').value= 'night';
var alist=document.querySelectorAll('a');
var i =0;
while(i<alist.length)
{
alist[i].style.color='blue';
i+=1;
}
}
">
<!-- button2 -->
<input id="night_day" type="button" value="night" onclick="
var target=document.querySelector('body');
if(this.value==='night')
{
target.style.backgroundColor= 'black';
target.style.color= 'white';
this.value= 'day';
}else{
target.style.backgroundColor= 'white';
target.style.color= 'black';
this.value= 'night';
}
">
<div id="grid">
<ol>
......