1
<p id="demo">单击按钮比较数值大小并返回最小值。</p>
2
<button onclick="myFunction()">点我</button>
3
<script>
4
function myFunction() {
5
var a = Math.min(5, 10);
6
var b = Math.min(0, 150, 30, 20, 38);
7
var c = Math.min(-5, 10);
8
var d = Math.min(-5, -10);
9
var e = Math.min(1.5, 2.5);
10
var x = document.getElementById("demo");
11
x.innerHTML = a + "<br>" + b + "<br>" + c + "<br>" + d + "<br>" + e;
12
}
13
</script>