<html>
<body>
<h2>JavaScript Math.random()</h2>
<p>每当您点击按钮,getRndInteger(min, max) 就会返回 0 与 9(均包含)之间的随机数:</p>
<button onclick="document.getElementById('demo').innerHTML = getRndInteger(0,10)">点击我</button>
<p id="demo"></p>
<script>
function getRndInteger(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
</script>
</body>
</html>