Multiple Choice Quiz
What is the capital of France?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Multiple Choice Quiz</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.7.4/css/uikit.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.7.4/js/uikit.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.7.4/js/uikit-icons.min.js"></script>
<style>
.answer {
cursor: pointer;
}
</style>
</head>
<body>
<div class="uk-container">
<h1>Multiple Choice Quiz</h1>
<div class="uk-card uk-card-default uk-card-body uk-margin-bottom">
<p>What is the capital of France?</p>
<div class="uk-margin">
<label class="answer uk-margin-right">
<input class="uk-checkbox" type="checkbox" value="false"> Paris
</label>
<label class="answer uk-margin-right">
<input class="uk-checkbox" type="checkbox" value="true"> Marseille
</label>
<label class="answer uk-margin-right">
<input class="uk-checkbox" type="checkbox" value="false"> Lyon
</label>
<label class="answer uk-margin-right">
<input class="uk-checkbox" type="checkbox" value="false"> Nice
</label>
</div>
</div>
</div>
<script>
const answerInputs = document.querySelectorAll('.answer input');
answerInputs.forEach(input => {
input.addEventListener('click', () => {
const isChecked = input.checked;
const label = input.parentNode;
if (isChecked) {
label.classList.remove('uk-text-danger');
label.classList.remove('uk-text-success');
if (input.value === 'true') {
label.classList.add('uk-text-success');
label.innerHTML += '<span uk-icon="check"></span>';
} else {
label.classList.add('uk-text-danger');
label.innerHTML += '<span uk-icon="close"></span>';
}
} else {
label.classList.remove('uk-text-danger');
label.classList.remove('uk-text-success');
label.innerHTML = label.textContent;
}
});
});
</script>
</body>
</html>