MinsoftK

test making and using function

......@@ -4,10 +4,38 @@
<title>KHU KHU Chat</title>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">
<style>
</style>
<script>
function nightDayHandler(self){
var target=document.querySelector('body');
if(this.value==='night')
{
target.style.backgroundColor= 'black';
target.style.color= 'white';
this.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';
this.value= 'night';
var alist=document.querySelectorAll('a');
var i =0;
while(i<alist.length)
{
alist[i].style.color='blue';
i+=1;
}
}
}
</script>
</head>
<body>
......@@ -85,48 +113,12 @@ 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;
}
}
nightDayHandler(this);
">
<!-- button2 -->
<!-- button2 making and using function -->
<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';
}
nightDayHandler(this);
">
<div id="grid">
......