강의 소개와 자바스크립트의 근본
이 강의는 문법나열 강의가 아님… 프로젝트와 문법공부 같이 가겠다.
그리고 혼자서도 코드 잘짜는 사고방식을 가르쳐주겠다.
첫번째로 개발환경셋팅하라.. 워크스페이스 만들고 index.html만들라.
vs코드 쓰는 사람은 live server 까세요. 이미 깔았습니다.
자바스크립트는 html문서를 조작하기 위해 만들어진 언어라서, index.html부터 시작하는 것이다.
자바스크립트는 원래 html문서를 조작하기 위해 만들어진 녀석이다…. 요즘에는 뭐 별걸다하긴 하지만..
앞으로 프로젝트를 진행하면서 하겠다. alert박스 하나 만들기임.
가장 간단한 것부터 조작해보자.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>index.html</title>
</head>
<body>
<h1 id = "hello">안녕하세요</h1>
</body>
</html>
이렇게 안녕하세요를 띄우는 코드가 있다고 해보자.
이걸 ‘안녕’으로 동적으로 바꾸고 싶다. how?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>index.html</title>
</head>
<body>
<h1 id = "hello">안녕하세요</h1>
<script>
**document.getElementById('hello').innerHTML = '안녕'**
</script>
</body>
</html>
이걸 닥치고 치라고 함… 그랬더니 안녕으로 바뀌었다.. ㅋㅋ
자스의 장점은 문법을 몰라도, 이미 쳐져있는 코드를 영어만 알면 해석하기 쉽다는 것임.