1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<!DOCTYPE html>
<html>
<head>
    <title>자바스크립트</title>
    <link rel="stylesheet" type="text/css" href="index.css">
</head>
 
<body>
    <h1 id="title">This Works!</h1>
 
    <script src="index.js">
        
    </script>
</body>
 
</html>
cs

1
2
3
4
5
6
7
8
9
10
11
12
13
const title = document.querySelector("#title");
 
// id="title"의 내용을 변경한다.
title.innerHTML = "Hi! From JS";
 
// id="title"의 글씨 색상을 변경한다,.
title.style.color = "red";
 
// title요소를 변경한다.
document.title = "I JS";
 
// 콘솔로 출력한다.
console.dir(title);  
cs



+ Recent posts