欢迎访问 如意编程网!

如意编程网

当前位置: 首页 > 前端技术 > HTML >内容正文

HTML

HTML + JS随机抽号。

发布时间:2022/11/16 HTML 20 老码农
如意编程网 收集整理的这篇文章主要介绍了 HTML + JS随机抽号。 小编觉得挺不错的,现在分享给大家,帮大家做个参考.
HTML + JS随机抽号。


【设置第三次抽取的号码为 (张三6)】
<script language="javascript"> var k = 0 ; function star(){ k++ ; loop() } var t ; var i ; var bs =true ; function loop(){ t = setTimeout( loop , 25 ) //时钟控件 var r = Math.random()*40 i = parseInt( r ) if( bs ){ $( $(".m")[i] ).css( "background-color" , "#ccff00" ) bs = false ; }else { $( $(".m") ).css( "background-color" , "#6666CC" ) bs = true ; } } function stop(){ clearTimeout( t ) if( k==3 ){ $( $(".m") ).css( "background-color" , "#6666CC" ) $( $(".m")[5] ).css( "background-color" , "#ccff00" ) }else{ $( $(".m")[i] ).css( "background-color" , "#ccff00" ) } } </script>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>随机抽号程序</title>
<style type="text/css">
<!--
body {
    background-attachment: scroll;
    background-image: url(images/sjxh.jpg);
    background-repeat: no-repeat;
    background-position: right center;
    background-color: #333333;
}
#title {
    height: 25px;
    width: 300px;
    margin-right: auto;
    margin-left: auto;
    font-size: 25px;
    font-weight: bolder;
    color: #FFFFFF;
    line-height: 25px;
    margin-bottom: 50px;
    margin-top: 20px;
}
#box {
    height: 356px;
    width: 890px;
    margin-right: auto;
    margin-left: auto;
}
#rmd {
    width: 300px;
    float: none;
    clear: left;
}
#stop {
    height: 50px;
    width: 120px;
    float: left;
    font-size: 25px;
    font-weight: bold;
    color: #FFFFFF;
    text-align: center;
    vertical-align: middle;
    line-height: 50px;
}
#star {
    font-size: 25px;
    line-height: 50px;
    font-weight: bold;
    color: #FFFFFF;
    height: 50px;
    width: 120px;
    margin-right: auto;
    margin-left: 35%;
    text-align: center;
    vertical-align: middle;
    float: left;
}
#star a {
    color: #FFFFFF;
    text-decoration: none;
    height: 50px;
    width: 120px;
    background-color: #33FF00;
    display: block;
}
#stop a {
    color: #FFFFFF;
    text-decoration: none;
    background-color: #FF0000;
    display: block;
    height: 50px;
    width: 120px;
}
.m {
    font-size: 22px;
    line-height: 60px;
    font-weight: bold;
    color: #FFFFFF;
    background-color: #6666CC;
    text-align: center;
    vertical-align: middle;
    float: left;
    height: 60px;
    width: 100px;
    margin: 5px;
    font-family: "微软雅黑";
}
body,td,th {
    font-family: 微软雅黑 Light;
    font-size: 20px;
    color: #FFFFFF;
    font-weight: bold;
}
-->
</style>
</head>
<script language="javascript" src="js/jquery-1.10.2.min.js"></script>
<script language="javascript">
          
        function star(){
            loop()
        }
          var t ;
          var i ;
          var bs =true ;
        function loop(){
             t = setTimeout( loop , 25 ) //时钟控件
             var r = Math.random()*40
             i = parseInt( r )
            
            if( bs ){
            $( $(".m")[i] ).css( "background-color" , "#ccff00" )
        bs = false ;
       }else {
            $( $(".m") ).css( "background-color" , "#6666CC" )
         bs = true ;
        }
         
     }
     
     function stop(){
         clearTimeout( t )
          $( $(".m")[i] ).css( "background-color" , "#ccff00" )
           var rm = document.createElement('div');
           rm.innerHTML = $( $(".m")[i] ).html();
           document.body.appendChild(rm);
     }
 </script>
<body>
<div id="title">网站随机抽号程序</div>
<div id="box">
  <div>张三1</div>
  <div>张三2</div>
  <div>张三3</div>
  <div>张三4</div>
  <div>张三5</div>
  <div>张三6</div>
  <div>张三7</div>
  <div>张三8</div>
  <div>张三9</div>
  <div>张三10</div>
  <div>张三11</div>
  <div>张三12</div>
  <div>张三13</div>
  <div>张三14</div>
  <div>张三15</div>
  <div>张三16</div>
  <div>张三17</div>
  <div>张三18</div>
  <div>张三19</div>
  <div>张三20</div>
  <div>张三21</div>
  <div>张三22</div>
  <div>张三23</div>
  <div>张三24</div>
  <div>张三25</div>
  <div>张三26</div>
  <div>张三27</div>
  <div>张三28</div>
  <div>张三29</div>
  <div>张三30</div>
  <div>张三31</div>
  <div>张三32</div>
  <div>张三33</div>
  <div>张三34</div>
  <div>张三35</div>
  <div>张三36</div>
  <div>张三37</div>
  <div>张三38</div>
  <div>张三39</div>
  <div>张三40</div>
  
</div>
<div id="star"><a href="#" onclick="star()">开始</a></div>
<div id="stop"><a href="#" onclick="stop()">停止</a></div>
<div id="rmd"></div>
</body>
</html>

 

 

总结

以上是如意编程网为你收集整理的HTML + JS随机抽号。的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得如意编程网网站内容还不错,欢迎将如意编程网推荐给好友。