์ฐ์ ๊ธฐ๋ก ๐ช
JavaScript ๋ด์ฉ์ ๋ฆฌ - 1 ๋ณธ๋ฌธ
https://opentutorials.org/course/3085
์๋ฐ ์คํฌ๋ฆฝํธ ๊ฐ์๋ ์ ๋งํฌ์์ ๋ณผ ์ ์๋ค.
์๋ฐ์คํฌ๋ฆฝํธ๋ฅผ ์ฌ์ฉํ๋ ค๋ฉด ๋ด์ฉ์ <script></script>ํ๊ทธ๋ก ๊ฐ์ธ์ฃผ์ด์ผ ํ๋ค.
๊ธ์ ์ฐ๋ ค๋ฉด ์๋์ ๊ฐ์ด ํ๋ค.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script>
document.write('hello world');
document.write(1+1);
</script>
<h1>HTML</h1>
<br>hello world</br>
<br>1+1</br>
</body>
</html>
HTML์ 1+1์ ์ ๋ ฅํ๋ฉด ๊ทธ๋๋ก ์ถ๋ ฅํ์ง๋ง ์๋ฐ์คํฌ๋ฆฝํธ๋ ์๋์ผ๋ก 2๋ผ๊ณ ๊ณ์ฐํ์ฌ ์ถ๋ ฅํ๋ค.
์ด๋ฒคํธ
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<input type="button" value="hi" onclick="alert('hi')">
</body>
</html>
์ด๋ ๊ฒ ์์ ๊ฐ์ด ์น ๋ธ๋ผ์ฐ์ ์์ ํน์ ํ ์ผ์ด ๋ฐ์ํ์ ๋ ๊ทธ๊ฒ์ ์ด๋ฒคํธ๋ผ๊ณ ํ๋ค.
https://linuxism.ustd.ip.or.kr/1705
์ ๋งํฌ์ ์ด๋ฒคํธ ๋ฆฌ์คํธ๊ฐ ์ ์ ๋ฆฌ๋์ด ์๋ค. ์ค์ต์ ์กฐ๊ธ ํด๋ณด์.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<input type="button" value="hi" onclick="alert('hi')">
<input type="text" onchange="alert('changed')">
<input type="text" onkeydown="alert('key down!')"
</body>
</html>
input type="text"๋ฅผ ์ ๋ ฅํ๋ฉด ๊ธ์๋ฅผ ์ ๋ ฅํ ์ ์๋ ์์๊ฐ ์นํ์ด์ง์ ์๊ธด๋ค.
์ฌ๊ธฐ์ onchange๋ ๊ฐ์ด ๋ฌด์ธ๊ฐ ๋ณํ๊ฐ ์๊ธด ๋ค ๋ง์ฐ์ค ์ปค์๊ฐ ์์ ๋ฐ๊นฅ์ ํด๋ฆญํ๊ฒ ๋๋ฉด ๋ฐ์ํ๋ค.
onkeydown์ ํค๊ฐ ์ ๋ ฅ๋๋ฉด ๋ฐ์ํ๋ค.
์ฝ์
์ด๋ฒ ์ค์ต์ ์ด ๋งํฌ์ ๋ค์ด๊ฐ์ ์งํํ ์ ์๋ค.
https://web-n.github.io/web2_javascript/
๋งํฌ์ ๋ค์ด๊ฐ์ ๊ฐ๋ฐ์ ๋๊ตฌ๋ฅผ ์ด๊ณ ์๋ ์ฝ๋๋ฅผ ์ ๋ ฅํด๋ณด์.
alert('The World Wide Web (abbreviated WWW or the Web) is an information space
where documents and other web resources are identified by Uniform Resource Locators (URLs),
interlinked by hypertext links, and can be accessed via the Internet.[1] English scientist
Tim Berners-Lee invented the World Wide Web in 1989. He wrote the first web browser computer
program in 1990 while employed at CERN in Switzerland.[2][3]
The Web browser was released outside of CERN in 1991, first to other research institutions
starting in January 1991 and to the general public on the Internet in August 1991.'.length)
์ด๋ ๊ฒ ์ฝ์์ฐฝ์ ์ด์ฉํด ๊ธ์์๋ฅผ ์ ์ ์๋ค. ๋ํ ์์์ ๋ณด๋ฉด ์ฝ์์ฐฝ์ ์ด์ฉํด ์ด๋ฒคํธ ๋น์ฒจ์๋ฅผ ์ ์ ํ๊ธฐ๋ ํ๋ ๋ฑ ๋ฌด๊ถ๋ฌด์งํ๊ฒ ์ฌ์ฉํ ์ ์๋ค. ๋์ค์ ๊ณต๋ถ๋ฅผ ํด์ ๊ผญ ์จ๋จน์ด ๋ณด๋๋ก ํ์.
'WEB > HTML+CSS+JS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
JavaScript ๋ด์ฉ์ ๋ฆฌ - 3 (0) | 2021.01.03 |
---|---|
JavaScript ๋ด์ฉ์ ๋ฆฌ - 2 (0) | 2021.01.02 |
CSS ๋ด์ฉ์ ๋ฆฌ - ์ ํ์ (0) | 2020.12.31 |
CSS ๋ด์ฉ์ ๋ฆฌ - 4 (0) | 2020.12.31 |
CSS ๋ด์ฉ์ ๋ฆฌ - 3 (0) | 2020.12.30 |