MinsoftK

test how to use object in js

......@@ -5,36 +5,38 @@
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">
<script>
function LinksSetColor(color){
var alist=document.querySelectorAll('a');
var i =0;
while(i<alist.length)
{
alist[i].style.color=color;
i+=1;
}
}
function bodySetColor(color){
document.querySelector('body').style.color= color;
}
function bodySetBackGruondColor(color){
document.querySelector('body').style.backgroundColor= color;
}
function nightDayHandler(self){
var target=document.querySelector('body');
if(self.value==='night')
{
target.style.backgroundColor= 'black';
target.style.color= 'white';
bodySetBackGruondColor('black')
bodySetColor('white');
self.value= 'day';
var alist=document.querySelectorAll('a');
var i =0;
while(i<alist.length)
{
alist[i].style.color='powderblue';
i+=1;
}
setColor('powderblue');
}else{
target.style.backgroundColor= 'white';
target.style.color= 'black';
bodySetBackGruondColor('white')
bodySetColor('black');
self.value= 'night';
var alist=document.querySelectorAll('a');
var i =0;
while(i<alist.length)
{
alist[i].style.color='blue';
i+=1;
}
setColor('blue');
}
}
}
</script>
</head>
<body>
......@@ -111,7 +113,10 @@ i+=1;
}
-->
<!-- button 1 usage array and Loop for chage style -->
<!-- button 1 usage array and Loop for chage style
self를 통한 input의 객체 지정해주기
지정해주기전에는 전역객체를 가르키게 된다.
-->
<input id="night_day" type="button" value="night" onclick="
nightDayHandler(this);
">
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<h1>how to make object</h1>
<script>
var coworkers = {
"designer":"minsung",
"programmer":"sdy"
};
document.write("programmer: "+coworkers.programmer+"<br>");
document.write("designer: "+coworkers.designer+"<br>");
coworkers.bookkeeper="duru";
document.write("bookkeeper: "+coworkers.bookkeeper+"<br>");
coworkers["data scientist"] ="taeho";
document.write("data scientist: "+coworkers["data scientist"]+"<br>");
</script>
<h2>iterate</h2>
<script>
for(var key in coworkers){
document.write(key+' : ' +coworkers[key]+'<br>');
}
</script>
</body>
</html>
<!doctype html>
<html>
<head>
<title>KHU KHU Chat</title>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">
<script>
var Links={
SetColor:function(color){
var alist=document.querySelectorAll('a');
var i =0;
while(i<alist.length)
{
alist[i].style.color=color;
i+=1;
}
}
}
var Body = {
SetColor:function(color){
document.querySelector('body').style.color= color;
},
SetBackGruondColor:function(color){
document.querySelector('body').style.backgroundColor= color;
}
}
function nightDayHandler(self){
if(self.value==='night')
{
Body.SetBackGruondColor('black')
Body.SetColor('white');
self.value= 'day';
Links.SetColor('powderblue');
}else{
Body.SetBackGruondColor('white')
Body.SetColor('black');
self.value= 'night';
Links.SetColor('blue');
}
}
</script>
</head>
<body>
<input id="night_day" type="button" value="night" onclick="
nightDayHandler(this);
">
<!-- button2 making and using function -->
<input id="night_day" type="button" value="night" onclick="
nightDayHandler(this);
">
<div id="grid">
<ol>
<li><a href="whatiskhuchat.html" class="saw">What is KHU chat? </a></li>
<li><a href="loginmain.html" class="saw">로그인</a></li>
<li><a href="signinmain.html" class="saw">회원가입</a></li>
<li><a href="question.html" class="saw">문의사항</a></li>
<li><a href="afterlogin.html" class="saw">로그인이후</a></li>
</ol>
<div id="article">
<h2>회원가입</h2>
<div id="inputset">
<form class="signinform" action="loginmain.html">
<label for="email">Email:</label><br>
<input type="text" name="email"><br>
<label for="password">password:</label><br>
<input type="password" name="password"><br>
<label for="name">이름:</label><br>
<input type="text" name="name"><br>
<label for="age">나이:</label><br>
<input type="text" name="age"><br><br>
<label for="sex">성별:</label><br>
<input type="radio" value="man" name="sex">남자<br>
<input type="radio" value="woman" name="sex">여자<br><br>
<label for="work">직업:</label><br>
<input type="radio" value="nowork" name="work">무직<br>
<input type="radio" value="Hstudent" name="work">중/고생<br>
<input type="radio" value="Ustudent" name="work">대학생<br>
<input type="radio" value="worker" name="work">직장인<br><br>
<label for="interesting">관심사(중복선택가능):</label><br>
<input type="checkbox" value="movie" name="interesting">영화<br>
<input type="checkbox" value="song" name="interesting">노래<br>
<input type="checkbox" value="study" name="interesting">공부<br>
<input type="checkbox" value="coding" name="interesting">코딩<br><br>
<input type="submit" value="회원가입신청">
</form>
</div>
</div>
</div>
</body>
</html>