<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<ul>
<li>๋ธ๊ธฐ</li>
<li>๋ฐ๋๋</li>
<li>์๋ฐ</li>
</ul>
<script>
this.onclick = function(e){
e.target.style.display="none";
}
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<ul>
<li>๋ธ๊ธฐ</li>
<li>๋ฐ๋๋</li>
<li>์๋ฐ</li>
</ul>
<script>
this.onclick=function(){
event.target.style.display="none";
}
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<ul>
<li id="a">๋ธ๊ธฐ</li>
<li id="b">๋ฐ๋๋</li>
<li id="c">์ฌ๊ณผ</li>
</ul>
<script>
this.onclick=function(e){
if(e.target.id=="a"){a.style.backgroundColor="red";
b.style.backgroundColor="white";
c.style.backgroundColor="white";}
if(e.target.id=="b"){b.style.backgroundColor="green";
a.style.backgroundColor="white";
c.style.backgroundColor="white";}
if(e.target.id=="c"){c.style.backgroundColor="blue";
a.style.backgroundColor="white";
b.style.backgroundColor="white";}
}
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#c {
cursor: pointer;
}
</style>
</head>
<body>
<ul>
<li id="a">๋ธ๊ธฐ</li>
<li id="b">๋ฐ๋๋</li>
<li id="c">์ฌ๊ณผ</li>
</ul>
<script>
this.onmouseover = function (e) {
if (e.target.id == "a") { a.style.backgroundColor = "red", a.style.cursor = "pointer" }
if (e.target.id == "b") { b.style.backgroundColor = "green"; }
if (e.target.id == "c") { c.style.backgroundColor = "blue"; }
}
this.onmouseout = function (e) {
if (e.target.id == "a") { a.style.backgroundColor = "white"; }
if (e.target.id == "b") { b.style.backgroundColor = "white"; }
if (e.target.id == "c") { c.style.backgroundColor = "white"; }
}
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
h1{
cursor: pointer;
}
</style>
</head>
<body>
<h1 id="ach">๋ฐฐ๊ฒฝ ์์ ๋ฐ๊พธ๊ธฐ</h1>
<script>
this.onclick=function(e){
if(e.target.id=="ach"){
var arrColor=["#ff0", "#6c0", "#fcf", "#cf0", "#39f"];
var arrNum=Math.floor(Math.random()*arrColor.length);
var bodyTag = document.getElementsByTagName("body")[0];
bodyTag.style.backgroundColor=arrColor[arrNum];
}
}
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p id="a">์๋
</p>
<p id="b">ํธํธํธ</p>
</body>
<script>
this.onclick = function(event){
if(event.target.id == "a"){a.style.color="red"; b.style.color="black";}
if(event.target.id == "b"){b.style.color="red"; a.style.color="black";}
}
</script>
</html>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p id="demo"></p>
<script>
const person = {
firstName: "John",
lastName: "Doe",
id: 5566,
fullName: function(){
return this.firstName + " " + this.lastName;
}
};
document.getElementById("demo").innerHTML = person.fullName();
</script>
</body>
</html>
'JavaScript > ๊ธฐ๋ณธ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๊ฐ์ฒด (์ต์, ์ต๋ ํ๊ท ) (0) | 2022.06.29 |
---|---|
๊ฐ์ฒด (์์ฑ์) (0) | 2022.06.24 |
๊ฐ์ฒด (0) | 2022.06.24 |
์๋ฐ์คํฌ๋ฆฝํธ ์ฐธ๊ณ ์ฌ์ดํธ (0) | 2022.06.23 |
์ด๋ฒคํธ (0) | 2022.06.23 |
๋๊ธ