zoukankan      html  css  js  c++  java
  • JS生成随机数

        

    随机数min代码和阅读代码如下:

    <html>
        <head>
            <title>randValue</title>
            <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
            <script language="javascript">
                maxN=6;
                function show(){
                    document.getElementById("msg").innerHTML=(msg.innerHTML=="?"?Math.ceil(Math.random()*maxN):"?");
                }
                function set(){
                    maxN=parseInt(prompt("Please set the maximum value.","6"));
                    if(isNaN(maxN)){
                        maxN=6;
                        alert("Wrong number,using 6 instead.");
                    }
                }
            </script>
            <style type="text/css">
            .stbig {
                font-size: 128px;
                font-weight: bold;
            }
            </style>
        </head>
        <body bgcolor="FFCCFF"><br><br>
            <p align="center" class="stbig" id="msg" onClick="show()">?</p>
            <h1 align="center" onClick="set()">Setting</h1>
        </body>
    </html>

    随机验证码代码如下(len值可改):

  • 相关阅读:
    Git`s Operation
    从volatile说到,i++原子操作,线程安全问题
    sql中的几种删除方式
    Hibernate&MyBatis different
    集合问答
    Data Struct and Data Type
    Hash table and application in java
    idea`s shortcut key
    001--idea第一个报错JNI报错
    recyclebin
  • 原文地址:https://www.cnblogs.com/leisureeen/p/13472035.html
Copyright © 2011-2022 走看看