JS简单随机数生成方法
摘要:本文实例讲述了JS简单随机数生成方法。分享给大家供大家参考,具体如下:随机数functionRandnum(value){vars=1000...
本文实例讲述了JS简单随机数生成方法。分享给大家供大家参考,具体如下:
<!doctype html> <html> <head> <meta charset="utf-8"> <title>随机数</title> </head> <body> <script type="text/javascript"> function Randnum(value){ var s=1000; var d=500; if(value=='b'){ document.write(s+parseInt(500*Math.random())); }else{ document.write(d+parseInt(500*Math.random())); } } </script> <script>Randnum();</script> </body> </html>
效果图:
希望本文所述对大家JavaScript程序设计有所帮助。
【JS简单随机数生成方法】相关文章:
上一篇:
使用React实现轮播效果组件示例代码