<html lang="ja">
<head>
<meta charset="UTF-8">
<title>html練習</title>
</head>
<body>
<img src="https://mmm.xtu.jp/wp-content/uploads/2023/05/omikuji-3.png">
<input id="omikuji" type="button" value="おみくじを引く">
<script>
document.getElementById("omikuji").onclick = function(){
let rnd = Math.floor( Math.random() * 6 );
switch(rnd){
case 0:
omikuji = "大吉";
break;
case 1:
omikuji = "吉";
break;
case 2:
omikuji = "中吉";
break;
case 3:
omikuji = "小吉";
break;
case 4:
omikuji = "末吉";
break;
case 5:
omikuji = "凶";
break;
default:
omikuji = "吉";
break;
}
alert(omikuji);
console.log(omikuji)
}
</script>
</body>
</html> 