const divInnerHtml = document.querySelector("div");
let count = 1;
const handleOnClick = () => {
if (count % 2 === 0) {
divInnerHtml.innerHTML("์ง์ง์ง๐");
} else {
divInnerHtml.innerHTML("ํํํ๐
");
}
count += 1;
};
๐ div์ id๋ฅผ ์ฃผ์ด๋ด.
๐ innerHtml์ innerText๋ก ๋ฐ๊ฟ๋ด.
๐ ๋๋ฒ๊น ๊ณผ์ ์ค, innerHtml๋ฉ์๋๊ฐ ํจ์๊ฐ ์๋๋ผ๋ ๊ฑธ ์๊ฒ๋จ.
const divInnerHtml = document.querySelector("div");
let count = 1;
const handleOnClick = () => {
if (count % 2 === 0) {
divInnerHtml.innerHTML = "์ง์ง์ง๐";
} else {
divInnerHtml.innerHTML = "ํํํ๐
";
}
count += 1;
};
๐ innerHtml ๋ฉ์๋๋ ํจ์ ํธ์ถ ๋ฐฉ์์ด ์๋ ์์ฑ๊ฐ์ ๋ณ๊ฒฝํ๋ ๋ฐฉ์์ผ๋ก ์ฌ์ฉํ๋ค.