일자 : 9주차 2차시
id = "id명" 속성을 지정한다.#을 참고하여 접근한다.<html>
<head>
<style>
#special{
background-color : yellow;
color : red;
}
</style>
</head>
<body>
<p id = "special">id selector</p>
</body>
</html>
class = "class명" 속성을 지정한다..을 참고하여 접근한다.<html>
<head>
<style>
.special{
background-color : yellow;
color : red;
}
</style>
</head>
<body>
<p class = "special">class selector</p>
<h1 class = "special">class selector</h1>
</body>
</html>
태그에 바로 #id명 또는 .class명을 작성하여 접근한다.<html>
<head>
<style>
p#special{
background-color : yellow;
color : red;
}
h2#special{
background-color : yellow;
color : blue;
}
</style>
</head>
<body>
<p id = "special">id selector</p>
<h2 id = "special">id selector</h2>
</body>
</html>
<html>
<head>
<style>
p, h2{
background-color : yellow;
color : red;
}
</style>
</head>
<body>
<p>id selector</p>
<h2>id selector</h2>
</body>
</html>
#id명을 삽입하여 '북마크' 기능처럼 사용할 수 있다.<html>
<body>
<p><a href="#C4">Jump to Chapter 4</a></p>
<h2>Chapter 1</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 2</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 3</h2>
<p>This chapter explains ba bla bla</p>
<h2 id="C4">Chapter 4</h2>
</body>
</html>
<script>
function myFunction() {
var x = document.getElementsByClassName('city');
for (var i = 0; i < xlength; i++){
x[i].style.display = "none";
}
}
</script>
<script>
function myFunction() {
document.getElementById('myHeader').innerHTML = 'Have a nice day';
}
</script>
