Step 1: Three Screens چالش 1 از جلسهی 16، آسان
قدم ۱: همهی HTML و CSS آزمونساز آماده است. تابع show(name) را بنویس: همهی .screenها را پنهان کند، صفحهی name را نشان بدهد، کلاس active را از همهی nav buttonها بردارد و به "tab-" + name بدهد. آخر اسکریپت show("make") را صدا بزن.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Quiz Maker</title>
<style>
body { font-family: sans-serif; margin: 0; background-color: #f4f1ff; }
header { background-color: #6c4ad6; color: white; padding: 12px 16px; }
.screen { max-width: 420px; margin: 0 auto; padding: 16px 16px 90px; }
label { display: block; margin-top: 8px; }
input { font-size: 16px; min-height: 44px; width: 100%; box-sizing: border-box; }
.screen button { font-size: 16px; min-height: 44px; margin-top: 8px; }
nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background-color: white; }
nav button { flex: 1; min-height: 56px; font-size: 16px; border: none; background-color: white; }
nav button.active { background-color: #ffd23f; font-weight: bold; }
</style>
</head>
<body>
<header><h1>Quiz Maker</h1></header>
<section class="screen" id="make">
<h2>Make questions</h2>
<form id="makeForm">
<label for="q">Question</label>
<input id="q" placeholder="What is 2 + 3?">
<label for="a">Right answer</label>
<input id="a" placeholder="5">
<button>Add question</button>
</form>
<p id="qcount">Questions: 0</p>
<ul id="qlist"></ul>
</section>
<section class="screen" id="play">
<h2>Quiz</h2>
<button id="startBtn" type="button">Start</button>
<p id="progress"></p>
<p id="time"></p>
<p id="question">Press Start!</p>
<form id="answerForm">
<label for="answer">Your answer</label>
<input id="answer">
<button>Check</button>
</form>
<p id="note"></p>
</section>
<section class="screen" id="score">
<h2>Score</h2>
<p id="result">No quiz yet</p>
<p id="message"></p>
<p id="best"></p>
<button id="again" type="button">Play again</button>
</section>
<nav>
<button id="tab-make" onclick="show('make')">Make</button>
<button id="tab-play" onclick="show('play')">Play</button>
<button id="tab-score" onclick="show('score')">Score</button>
</nav>
<script>
function show(name) {
// hide every .screen, show the one called name, and mark its tab active
}
</script>
</body>
</html>
راهنما و جواب این چالش · برگشت به درس جلسهی 16: پروژه: آزمونساز · چالش بعدی: Step 2: Make Questions
بیشتر بخوان: جاوااسکریپت چیست؟ از دکمهی وب تا Node.js