So I'm trying to make a randomizer that goes from 0 - 8. I have a button that you click in order to get the number. It is an empty paragraph with an id. Here's my code:
HTML:
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script type="text/javascript" src="tf2generator.html"></script>
</head>
<body>
<p id="changer"> </p>
<button onclick = Randomizer()> Button </button>
</body>
</html>
External JS:
function Randomizer(){
let randomnum = Math.floor(Math.random() * 8);
document.getElementById("changer").innerHTML = randomnum;
}
This literally makes no sense on why it doesn't work, please help.
Aucun commentaire:
Enregistrer un commentaire