本文實(shí)例講述了JavaScript使用Math.Min返回兩個(gè)數(shù)中較小數(shù)的方法。分享給大家供大家參考。具體如下:
下面JavaScript通過Math.Min返回兩個(gè)數(shù)中較小的那個(gè)
<!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>運(yùn)行上面代碼得到數(shù)字為5
希望本文所述對大家的javascript程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答