日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

jquery实现抽奖系统

發布時間:2025/3/19 windows 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 jquery实现抽奖系统 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

閑來無事做了一個抽獎的系統:

????

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>抽獎系統</title>

<script src="source/jquery.js"></script>

<style>

#box{

width:450px;

margin:0 auto;

}

.show{

width:100px;

height:55px;

text-align:center;

background:#ff0;

line-height:55px;

border:1px solid #000;

border-radius:5px;

font-size:20px;

font-family:微軟雅黑;

float:left;

margin:5px 5px 0px 5px;

}

#person{

width:450px;

height:100px;

background:#ff0;

text-align:center;

line-height:100px;

font-size:45px;

margin:0 auto;

margin-top:25px;

border:1px dotted #000;

font-family:楷體;

border-radius:10px;

}

p{

margin-top:25px;

text-align:center;

}

button{

width:65px;

height:35px;

text-align:center;

border:0px;

border-radius:5px;

background:#f36;

font-size:16px;

color:#fff;

cursor:pointer;

}

.active{

background:#f00;

}

</style>

</head>

<body>

<div id='box'>

<div class="show">吳澤輝</div>

<div class="show">李景亮</div>

<div class="show">李志偉</div>

<div class="show">潘雅靜</div>

<div class="show">王建華</div>

<div class="show">高強</div>

<div class="show">秦英</div>

<div class="show">高文幸</div>

<div class="show">李雪</div>

<div class="show">高丹</div>

<div class="show">崔小剛</div>

<div class="show">趙艷萍</div>

<div class="show">于曉麗</div>

<div class="show">于洋</div>

<div class="show">胡小萌</div>

<div class="show">武淵</div>

</div>

<div style="clear:both"></div>

<div id="person">

獲獎者

</div>

<p>

<button id="btn">開始</button>

</p>

</body>

<script>

var showlen=$('.show').length; //獲取人員總數

var time=null; //初始化計時器


$('#btn').click(function(){

var flag=$(this).html();

flag=flag=='開始'?'停止':'開始'; //交換按鈕上的內容

$(this).html(flag);


switch(flag)

{

case '停止': //這里是開始作抽獎

getIndex(0);

break;


case '開始': //這里是停止循環

getIndex(1);

$('#person').html('恭喜:'+$("#person").html()); //匯報結果

break;

}

});


function getIndex(mark)

{

if(mark==1)

{

clearInterval(time); //終止計時器

}

else

{

time=setInterval(show,1); //開啟計時器

}


function show()

{

var idx=Math.floor(Math.random()*showlen); //生成隨機數

for(var i=0;i<showlen;i++)

{

$('.show').eq(i).css({'background':'#ff0'}); //去掉所有的背景色

}

$('.show').eq(idx).css({'background':'#f00'}); ?//為當前選中的人加背景色

$("#person").html($('.show').eq(idx).html()); ?//將當前選中的人的名字顯示在下面的框內

}

}

</script>

</html>


試用效果還可以.如圖:

????

轉載于:https://blog.51cto.com/phpwzh/1717906

總結

以上是生活随笔為你收集整理的jquery实现抽奖系统的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。