-
-
Save nancystodd/fd6178ce5938f9804ff7326d1f9f55a8 to your computer and use it in GitHub Desktop.
Generate a random number into html with jQuery process.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
</head> | |
<body> | |
<p><a href="no-javascript.html" id="getNumber">Générer</a> un nombre aléatoire. </p> | |
<h2 id="result"></h2> | |
<script> | |
var link = document.getElementById('getNumber'); | |
link.onclick = getNumber; | |
function getNumber() { | |
var minNumber = 1; // le minimum | |
var maxNumber = 100; // le maximum | |
var randomnumber = Math.floor(Math.random() * (maxNumber + 1) + minNumber); // la fonction magique | |
$('#result').html(randomnumber); | |
return false; | |
} | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment