我是靠谱客的博主 粗心猫咪,这篇文章主要介绍js生成1-10之间的随机整数,现在分享给大家,希望可以做个参考。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<script> //随机整数 <!doctype html> <html> <head> <meta charset="utf-8"> <title>layer-更懂你的web弹窗解决方案</title> <script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script> <script src="layer/layer.js"></script> </head> <body> <button id="test2" class="button">运行上述例子</button> <script> //随机整数 var n1=Math.floor(Math.random()*10+1);//输出1~10之间的随机整数 var n2=parseInt(10*Math.random());//输出0~10之间的随机整数 //弹出一个页面层 $('#test2').on('click', function(){ layer.prompt({   title: '请输入验证码:'+n1+"+"+n2+"=",   formType: 0 //prompt风格,支持0-2 }, function(pass){        var n3=n1+n2;    if(n3==pass){//判断填写的检证码是否正确  layer.prompt({title: pass+'随便写点啥,并确认', formType: 2}, function(text){  layer.msg('演示完毕!您的口令:'+ pass +' 您最后写下了:'+ text);       }); } }); }); </script> </body> </html>

最后

以上就是粗心猫咪最近收集整理的关于js生成1-10之间的随机整数的全部内容,更多相关js生成1-10之间内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(80)

评论列表共有 0 条评论

立即
投稿
返回
顶部