简易双色球dome分享

代码如下:

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
42
43
44
<style type="text/css">
    div {font-weight: bold;text-align: center;}
    .tone{width: 30px;height:30px;border: 2px solid #ff5151;border-radius: 18px;float: left;
    font-size: 14px;color:#000000;color:#ff5959;line-height: 30px;margin-left: 5px;}
    #tone6{border:2px solid #3ea1f4;color: #3ea1f4;}
    #clickme{width: 120px;height: 25px;margin-top: 5px;margin-left: 20px;}
</style>
<div class="center">
    <div id="tone0" class="tone"></div>
    <div id="tone1" class="tone"></div>
    <div id="tone2" class="tone"></div>
    <div id="tone3" class="tone"></div>
    <div id="tone4" class="tone"></div>
    <div id="tone5" class="tone"></div>
    <div id="tone6" class="tone"></div>
</div>
 
 
<button type="button" id="clickme" onclick="run()">点我生成双色球</button>
 
<script type="text/javascript">
    function run(){
        var reds=[parseInt(Math.random()*32+1)];
        var blues=parseInt(Math.random()*15+1);
 
        while(reds.length<6){
            var r=parseInt(Math.random()*32);
            //循环遍历reds数组
            for(var i=0;i<reds.length;i++){
                if(reds[i]==r){
                    break;
                }else if(i==reds.length-1){
                    reds.push(r);
                    //console.log(reds);
                }
            }
        }
        for(var j=0;j<reds.length;j++){
            document.getElementById("tone"+j+'').innerHTML=reds[j];
        }
        document.getElementById("tone6").innerHTML=blues;
    }
    run();
</script>

效果如下:

 

posted @   林恒  阅读(247)  评论(0编辑  收藏  举报
编辑推荐:
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
· C++代码改造为UTF-8编码问题的总结
阅读排行:
· 【.NET】调用本地 Deepseek 模型
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
欢迎阅读『简易双色球dome分享』
点击右上角即可分享
微信分享提示