๋ชจ๋ ํฌ์คํ
์ ์ธํ๋ฐ [์ํ์ฝ๋ฉ] ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์์ ๋ด์ฉ์ ๋ด๊ณ ์์ผ๋ฉฐ
์ถ์ฒ๋ ์๋์ ์ฃผ์๋ก "egoing Lee"๋์ ์๋ฃ์
๋๋ค.
์์
์ ์ธ ์๋๊ฐ ์๋ ๊ณต๋ถํ ๊ฒ์ ์ ๋ฆฌํด๋๋ ๋ชฉ์ ์ผ๋ก ํฌ์คํ
ํ ๊ฒ์
๋๋ค.
www.inflearn.com/course/javascript-%EC%9E%90%EB%B0%94%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8-%EA%B0%95%EC%A2%8C#
์น๋ธ๋ผ์ฐ์ Javascript (์๋ฐ์คํฌ๋ฆฝํธ) - ์ธํ๋ฐ
์ํ์ฝ๋ฉ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ข ์
๋๋ค. ์น๋ธ๋ผ์ฐ์ ๋ฅผ ์ง์ ์ ์ดํ ์ ์๋ ์๋ฐ์คํฌ๋ฆฝํธ ๋ ํผ๋ฐ์ค๋ฅผ ๊ณต๋ถํด ๋ด
๋๋ค. ์ด๊ธ ์น ๊ฐ๋ฐ ํ๋ก๊ทธ๋๋ฐ ์ธ์ด JavaScript ์จ๋ผ์ธ ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ข
www.inflearn.com
HTMLCollection
HTMLCollection์ ๋ฆฌํด ๊ฒฐ๊ณผ๊ฐ ๋ณต์์ธ ๊ฒฝ์ฐ์ ์ฌ์ฉํ๊ฒ ๋๋ ๊ฐ์ฒด์ด๋ค. ์ ์ฌ๋ฐฐ์ด๋ก ๋ฐฐ์ด๊ณผ ๋น์ทํ ์ฌ์ฉ๋ฐฉ๋ฒ์ ๊ฐ์ง๊ณ ์์ง๋ง ๋ฐฐ์ด์ ์๋๋ค.
HTMLCollection
Document Object Model HTML
1.6.1. Property Attributes HTML attributes are exposed as properties on the element object. The DOM naming conventions always determine the name of the exposed property, and are independent of the case of the attribute in the source document. The data type
www.w3.org
HTMLCollection์ ๋ชฉ๋ก์ ์ค์๊ฐ์ผ๋ก ๋ณ๊ฒฝ๋๋ค. ์๋ ์ฝ๋๋ฅผ ๋ณด์.
<!DOCTYPE html>
<html>
<body>
<ul>
<li>HTML</li>
<li>CSS</li>
<li id="active">JavaScript</li>
</ul>
<script>
console.group('before');
var lis = document.getElementsByTagName('li');
for(var i = 0; i < lis.length; i++){
console.log(lis[i]);
}
console.groupEnd();
console.group('after');
lis[1].parentNode.removeChild(lis[1]);// CSS๋ฅผ ์ญ์ ํ ๊ฒ๊ณผ ๋์ผ ํ ๊ฒ. ์ฆ li์ 2๋ฒ์งธ๋ฅผ ์ญ์
for(var i = 0; i < lis.length; i++){
console.log(lis[i]);
}
console.groupEnd();
</script>
</body>
</html>
์์ ์ฝ๋์ค์์ console.group ๊ณผ console.groupEnd์ ์ญํ ์ ๊ทธ ์ฌ์ด์ ์๋ ๊ฐ๋ค์ ์ฝ์์์ ์ถ๋ ฅ์ํฌ ๋, ๊ทธ ๊ฐ์ ํ๋ฒ์ ๋ฌถ์ด์(๊ทธ๋ฃนํ) ์๋์ ๊ฐ์ด ์ถ๋ ฅ์์ผ์ฃผ๋ ์ฉ๋๋ก ์ฌ์ฉ๋๋ ๋ฉ์๋์ด๋ค.
๊ฒฐ๊ณผ๋ ์๋์ ๊ฐ์ด ์ถ๋ ฅ๋๋ค.
์ฆ ๋ชฉ๋ก์ด ์ญ์ ํ๋ ๊ฒ์ ๋ํด ์ฆ์, ๋ณ๊ฒฝ ๋์์์ ํ์ธํ ์ ์๋ค.