728x90
์๋ฐ์คํฌ๋ฆฝํธ : ํด์ฆ ํจ๊ณผ
์๋ฐ์คํฌ๋ฆฝํธ์ ๋ค์ํ ํจ๊ณผ๋ค ์ค, ํด์ฆ๋ฅผ ๋งํ ์ ์๋ ํด์ฆ ํจ๊ณผ์ ๋๋ค. ๊ทธ ์ค์์๋, ์ ๋ต์ ์ ๋ ฅํ์ง ์๊ณ ์ ๋ต์ ํ์ธํ ์ ์๋ ํด์ฆ ์ ํ์ ์์ ํด ๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค.
์ ๋ต ํ์ธํ๊ธฐ ์ ํ
์์๋ ์น๋์์ธ๊ธฐ๋ฅ์ฌ์ ํ๊ธฐ ์ํ ๋ฌธ์ ์ ๋๋ค. '์ ๋ต ํ์ธํ๊ธฐ' ๋ฒํผ์ ๋๋ฅด๋ฉด ๋ฌธ์ ์ ์ ๋ต์ ํ์ธํ ์ ์์ต๋๋ค.
// ์ ํ์
const quizType = document.querySelector(".quiz__type"); // ํด์ฆ ์ข
๋ฅ
const quizNumber = document.querySelector(".quiz__question .number"); // ํด์ฆ ๋ฒํธ
const quizAsk = document.querySelector(".quiz__question .ask"); // ํด์ฆ ์ง๋ฌธ
const quizConfirm = document.querySelector(".quiz__answer .confirm"); // ์ ๋ต ํ์ธ ๋ฒํผ
const quizResult = document.querySelector(".quiz__answer .result"); // ์ ๋ต ๊ฒฐ๊ณผ
// ๋ฌธ์ ์ ๋ณด
const answerType = "์น๋์์ธ๊ธฐ๋ฅ์ฌ";
const answerNum = 1;
const answerAsk = "์ธ์ ํ๋ ๋ ์์ ๊ฒฝ๊ณ ๋ถ๋ถ์ ์์, ๋ช
๋, ์ฑ๋์ ๋๋น๊ฐ ๋์ฑ ๊ฐํ๊ฒ ์ผ์ด๋๋ ํ์์ ๋ฌด์์ด๋ผ๊ณ ํ๋๊ฐ?";
const answerResult = "์ฐ๋ณ๋๋น";
// ๋ฌธ์ ์ถ๋ ฅ : ์ ํ์, ์์ ๋ฉ์๋, ๋ณ์ ์์๋ก ์์ฑ
quizType.innerText = answerType;
quizNumber.innerText = answerNum + ". ";
quizAsk.innerText = answerAsk;
quizResult.innerHTML = answerResult;
// ์ ๋ต ์จ๊ธฐ๊ธฐ : style์ ์ฃผ๋ ๋ฐฉ๋ฒ
quizResult.style.display = "none";
// ์ ๋ต ํ์ธ
// ์ ๋ต ๋ฒํผ์ ํด๋ฆญํ๋ฉด ํ์ธ ๋ฒํผ ์จ๊ธฐ๊ณ , ์จ๊ฒจ์ง ์ ๋ต ๋ํ๋ด๊ธฐ
quizConfirm.addEventListener("click", function(){
quizConfirm.style.display = "none";
quizResult.style.display = "block";
});
728x90
'Javascript Effect' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
์๋ฐ์คํฌ๋ฆฝํธ ๊ฒ์ ํจ๊ณผ : includes() (4) | 2022.08.17 |
---|---|
์๋ฐ์คํฌ๋ฆฝํธ ๊ฒ์ ํจ๊ณผ : indexOf() (5) | 2022.08.17 |
์๋ฐ์คํฌ๋ฆฝํธ ํด์ฆ ํจ๊ณผ : ๊ฐ๊ด์ ์ ํ (13) | 2022.08.08 |
์๋ฐ์คํฌ๋ฆฝํธ ํด์ฆ ํจ๊ณผ : ์ฃผ๊ด์(์ฌ๋ฌ ๋ฌธ์ ) ์ ํ (11) | 2022.08.06 |
์๋ฐ์คํฌ๋ฆฝํธ ํด์ฆ ํจ๊ณผ : ์ฃผ๊ด์ ์ ํ (9) | 2022.08.04 |
๋๊ธ