本文实例讲述了JavaScript使用Math.Min返回两个数中较小数的方法。分享给大家供大家参考。具体如下:
下面JavaScript通过Math.Min返回两个数中较小的那个
<!DOCTYPE html><html><body><p id="demo">Click the button to return the lowest number of 5 and 10.</p><button onclick="myFunction()">Try it</button><script>function myFunction(){document.getElementById("demo").innerHTML=Math.min(5,10);}</script></body></html>
运行上面代码得到数字为5
希望本文所述对大家的javascript程序设计有所帮助。
新闻热点
疑难解答