Wu Yuxiong - natural born JAVASCRIPT development of learning: Math (arithmetic) objects

<! DOCTYPE HTML > 
< HTML > 
< head > 
< Meta charset = "UTF-. 8" > 
< title > novice tutorial (runoob.com) </ title > 
</ head > 
< body > 

< P ID = "Demo" > click the button to rounding and "2.5" nearest integer </ the p- > 
< the button onclick = "myFunction ()" > point I </ the button > 
< Script >
function myFunction(){
    document.getElementById("demo").innerHTML=Math.round(2.5);
}
</script>

</body>
</html>
<! DOCTYPE HTML > 
< HTML > 
< head > 
< Meta charset = "UTF-. 8" > 
< title > novice tutorial (runoob.com) </ title > 
</ head > 
< body > 

< P ID = "Demo" > click the button to display a random number </ the p- > 
< the button onclick = "myFunction ()" > point I </ the button > 
< Script >
function myFunction(){
    document.getElementById("demo").innerHTML=Math.random();
}
</script>

</body>
</html>

<! DOCTYPE HTML > 
< HTML > 
< head > 
< Meta charset = "UTF-. 8" > 
< title > novice tutorial (runoob.com) </ title > 
</ head > 
< body > 

< P ID = "Demo" > click the button to return maximum value between 5-10. </ The p- > 
< the Button onclick = "myFunction ()" > point I </ the Button > 
< Script >

    document.getElementById("demo").innerHTML=Math.max(5,10);
}
</script>

</body>
</html>

<! DOCTYPE HTML > 
< HTML > 
< head > 
< Meta charset = "UTF-. 8" > 
< title > novice tutorial (runoob.com) </ title > 
</ head > 
< body > 

< P ID = "Demo" > click the button to return to the minimum value between 5-10. </ The p- > 
< the Button onclick = "myFunction ()" > point I </ the Button > 
< Script >

    document.getElementById("demo").innerHTML=Math.min(5,10);
}
</script>

</body>
</html>

 

Guess you like

Origin www.cnblogs.com/tszr/p/10944811.html