All I'm trying to do is have the user click a button to generate a random number. It seems to work, but the number only displays for a second before disappearing. Here is my code.
<!DOCTYPE html>
<head>
</head>
<body>
<h3>
This is a random number generator!
</h3>
<form onsubmit= "randomNumber()">
<input type="submit" value="Click me!">
</form>
<script>
function randomNumber() {
document.write(Math.floor(Math.random() * 10));
}
</script>
<p id="number">
</p>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire