首页 > 编程 > JavaScript > 正文

JavaScript使用Math.Min返回两个数中较小数的方法

2019-11-20 12:45:41
字体:
来源:转载
供稿:网友

本文实例讲述了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程序设计有所帮助。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表