๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
EFFECT

ํ€ด์ฆˆ ๋ฌธ์ œ ๋งŒ๋“ค๊ธฐ01

by _ํ† ๋งคํ†  2022. 8. 4.
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 quizView = document.querySelector(".quiz__view"); //๊ฐ•์•„์ง€

//๋ฌธ์ œ์ •๋ณด
const answerType = "์›น๋””์ž์ธ๊ธฐ๋Šฅ์‚ฌ";
const answerNum = "1";
const answerAsk = "์ธ์ ‘ํ•˜๋Š” ๋‘ ์ƒ‰์˜ ๊ฒฝ๊ณ„ ๋ถ€๋ถ„์— ์ƒ‰์ƒ, ๋ช…๋„, ์ฑ„๋„์˜ ๋Œ€๋น„๊ฐ€ ๋”์šฑ ๊ฐ•ํ•˜๊ฒŒ ์ผ์–ด๋‚˜๋Š” ํ˜„์ƒ์„ ๋ฌด์—‡์ด๋ผ๊ณ  ํ•˜๋Š”๊ฐ€?";
const answerResult = "์—ฐ๋ณ€๋Œ€๋น„";

// ๋ฐ์ดํ„ฐ ์ €์žฅ //

//๋ฌธ์ œ ์ถœ๋ ฅ
quizType.innerText = answerType;
quizNumber.innerText = answerNum + ". ";
quizAsk.innerText = answerAsk;
quizResult.innerText = answerResult;

//์ •๋‹ต์ˆจ๊ธฐ๊ธฐ
quizResult.style.display = "none"

//์ •๋‹ตํ™•์ธ ๋ฒ„ํŠผ
//๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๋ฉด ํ™•์ธ ๋ฒ„ํŠผ์„ ์•ˆ๋ณด์ด๊ฒŒ ํ•˜๊ณ  ์ˆจ๊ฒจ์ง„ ์ •๋‹ต์„ ๋ณด์ด๊ฒŒ ํ•ด์ค€๋‹ค.
//์ •๋‹ต์„ ํ™•์ธํ•˜๋ฉด ๊ฐ•์•„์ง€๊ฐ€ ์›ƒ๊ณ  ์žˆ์–ด์•ผ ํ•œ๋‹ค. // ํด๋ž˜์Šค like๋ฅผ ์ถ”๊ฐ€ํ–ˆ๊ธฐ ๋•Œ๋ฌธ
quizConfirm.addEventListener("click", function(){ 
    quizConfirm.style.display = "none"; //css ์Šคํƒ€์ผ
    quizResult.style.display = "block";
    quizView.classList.add("like");
});

!๊ธฐ์–ตํ•ด์•ผ ํ•  ๋ฌธ๋ฒ•!

๋ฒ„ํŠผ์„ ํด๋ฆญํ•  ๋•Œ ์ •๋‹ต์„ ๋ณด์ด๊ฒŒ ํ•ด์ค€๋‹ค.

quizResult.style.display = "block";

๋ฒ„ํŠผ์„ ํด๋ฆญํ–ˆ์„ ๋•Œ ์ด๋ฒคํŠธ๋ฅผ ์‹คํ–‰ํ•ด์ค€๋‹ค.

quizConfirm.addEventListener("click", function(){}    

๋ฒ„ํŠผ์„ ํด๋ฆญํ–ˆ์„ ๋•Œ ์ •๋‹ตํ™•์ธ๋ฒ„ํŠผ์„ ์ˆจ๊ฒจ์ค€๋‹ค. (์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋กœ CSS์Šคํƒ€์ผ ์„ ์–ธํ•˜๋Š” ๋ฐฉ๋ฒ•)

quizResult.style.display = "none" 

์š”์†Œ์— ํ…์ŠคํŠธ ์„ค์ •ํ•˜๊ธฐ

innerText()

๊ฒฐ๊ณผ๋ณด๊ธฐ

728x90

๋Œ“๊ธ€


Lucky Charms Rainbow
js
html
css