Programming

(Javascript) Math.random

steloflute 2012. 6. 18. 12:27

http://www.w3schools.com/jsref/jsref_random.asp

 

<!DOCTYPE html>
<html>
<body>

<p id="demo">Click the button to display a random number.</p>

<button onclick="myFunction()">Try it</button>

<script type="text/javascript">
function myFunction()
{
    document.getElementById("demo").innerHTML=Math.random();
}
</script>

</body>
</html>

 

Click the button to display a random number.

 

random.html