Create Your Own RPG Game: HTML Tutorial
<html>
<head>
<title>RPG Game</title>
</head>
<body>
<h1>RPG Game</h1>
<div>
<p>Welcome to the RPG game! Choose your hero:</p>
<div class='hero-choices'>
<button>Fighter</button>
<button>Mage</button>
<button>Thief</button>
</div>
</div>
<script>
let heroChoices = document.querySelector('.hero-choices');
heroChoices.addEventListener('click', (e) => {
console.log(e.target.innerText);
});
</script>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/lnvI 著作权归作者所有。请勿转载和采集!