A random number is useful in the creation of JavaScript applications such as random image script, random link generator.
To generate a random number between 1 and 10, simply use code example below:
<script type="text/javascript"> $(document).ready(function() { var rand_no = Math.ceil(10*Math.random()); alert(rand_no); }); </script> |
Where 10 dictates that the random number will fall between 0-10. To increase the range to, say, 100, simply change 10 to 100 instead.
