live, static
live -> document์ element๋ฅผ ์ถ๊ฐ/์ญ์ ํ์ ๋ ๋ฐ๋ก ๋ฐ์๋จ
static -> ๋ฐ๋ก ๋ฐ์๋์ง ์์
const buttons = document.getElementById("buttons");
const sports = document.querySelectorAll("sports");
const onClickHandler = () => {
const el = document.createElement("li"); //param์ ํ๊ทธ์ด๋ฆ์ผ๋ก ์๋ฆฌ๋จผํธ ์์ฑ, ๋คํ๋จผํธ์ ํํ๋๋ ค๋ฉด ๋
ธ๋์ ๋จผ์ ๋ฐ์๋์ด์ผํจ
el.textContext = "๋ฒํผ";
buttons.appendChild(el);
sports.appendChild(el); //nodeList๋ ๋ฐ๋ก ๋ฐ์๋์ง ์์
}
buttons.onClick = onClickHandler; //buttons๋ฅผ ํด๋ฆญํ๋ฉด ๋ง์ง๋ง child์ ์๊น
//๋
ธ๋ ํธ๋ฆฌ์ ๋
ธ๋(์๋ฆฌ๋จผํธ)๋ฅผ ์ถ๊ฐ/์ญ์ ํ๋ฉด HTMLCollection์ ์ถ๊ฐ๋๊ณ ๋ฐ๋ก ๋ฐ์๋จ
const el = document.createElementNS(namespace, "div");
<div xmlns:a="https://www.w3.org/TR/html5/" /> //namespace ์๋ฆฌ๋จผํธ๊ฐ์ ์ถฉ๋์ ๋ฐฉ์งํ๊ธฐ ์ํด URI๋ก ํํ
Last updated