<html>
<body>
<p>单击该按钮可显示 1 到 10 之间的随机数。</p>
<button onclick="myFunction()">试一试</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = Math.floor((Math.random() * 10) + 1);
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>