xxxxxxxxxx
<!DOCTYPE html>
<html>
<title>JavaScript 51到100之间的随机数生成示例 - 基础教程(div.cn)</title>
<body>
<h1>JavaScript Math.random() 方法</h1>
<p>单击按钮以显示51到100之间的随机数:</p>
<button onclick="myFunc()">Click</button>
<p id="result"></p>
<script>
function myFunc() {
let x = Math.floor((Math.random() * 50) + 51);
document.getElementById("result").innerHTML = x;
}
</script>
</body>
</html>