基本信息
源码名称:Jquery 摇奖 实例 附完整源码
源码大小:0.82KB
文件格式:.zip
开发语言:js
更新时间:2013-04-25
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
点击开始按钮 则开始摇奖,点击暂停显示 摇奖号码
<html> <head> <title>jQuery摇奖</title> <meta http-equiv="Content-Type" content="text/html; charset=utf8"> <script src="http://code.jquery.com/jquery-latest.js"></script> <style type="text/css"> body { text-align: center; } #number { font-size: 300px; } </style> <script type="text/javascript"> var max = 999; //随机函数 rnd.today=new Date(); rnd.seed=rnd.today.getTime(); function rnd() { rnd.seed = (rnd.seed*9301 49297) % 233280; return rnd.seed/(233280.0); }; function rand(number) { return Math.ceil(rnd()*number); }; //切换随机数 function addNum() { var i = rand(max); if(i < 10) { i = "00" i; } else if(i < 100) { i = "0" i; } $("#number").html(i); } $(document).ready(function() { //开始 随机数变换 $("#start").click(function() { if($("#flag").val() == 0) { t = setInterval("addNum()", 1); $("#flag").val(1); } }); //停止 中奖号码确定 $("#stop").click(function() { clearTimeout(t); $("#flag").val(0); }); }); </script> </head> <body> <div id="number">1</div> <input id="start" type="button" value="开始" /> <input id="stop" type="button" value="停止" /> <input id="flag" type="hidden" value="0" /> </body> </html>