Simple HTML Dice Roll Game - No Instructions Needed
<html>
<body>
<h1>Roll the Dice!</h1>
<p>Click on the dice to roll it and see what number you get!</p>
<img id='dice' src='dice1.png' onclick='rollDice()'>
<script>
function rollDice(){
let randomNumber = Math.floor(Math.random()*6) + 1;
let imgName = 'dice' + randomNumber + '.png';
document.getElementById('dice').src = imgName;
}
</script>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/lni8 著作权归作者所有。请勿转载和采集!