HTML Matching Game: Fun Shape Matching Challenge
<html>
<head>
<title>HTML Matching Game</title>
</head>
<body>
<h1>Matching Game</h1>
<h2>Match the shapes!</h2>
<div>
<img src='https://upload.wikimedia.org/wikipedia/commons/thumb/c/c9/Circle_-_black_simple.svg/1024px-Circle_-_black_simple.svg.png' alt='Circle' />
<img src='https://upload.wikimedia.org/wikipedia/commons/thumb/9/9d/Square_-_black_simple.svg/1024px-Square_-_black_simple.svg.png' alt='Square' />
<img src='https://upload.wikimedia.org/wikipedia/commons/thumb/4/4e/Triangle_-_black_simple.svg/1024px-Triangle_-_black_simple.svg.png' alt='Triangle' />
</div>
<div>
<button onclick='checkAnswer(1)'>Circle</button>
<button onclick='checkAnswer(2)'>Square</button>
<button onclick='checkAnswer(3)'>Triangle</button>
</div>
<div id='result' style='display: none;'>
<p>Correct!</p>
</div>
<script>
let correctAnswer = 2;
function checkAnswer(answer) {
if (answer === correctAnswer) {
document.getElementById('result').style.display = 'block';
}
}
</script>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/lmtb 著作权归作者所有。请勿转载和采集!