html

<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>抽号</title>
<script type="text/javascript" src="js/jquery.1.11.3.main.js" ></script>
<script type="text/javascript" src="js/main.js" ></script>
<link rel="stylesheet" type="text/css" href="css/css.css" />
</head> <body> <audio id="myMusic" loop src="img/Hans Zimmer - Up Is Down.mp3" type="audio/mpeg"></audio> <section>
<label>
起始值:<input type="number" id="begin" value="1" min="1" max="10000" />
</label>
<label>
结束值:<input type="number" id="end" value="5000" min="1" max="50000" />
</label> <div class="showNum" id="showNum">大家好,这是我的抽奖号</div><br /> <footer>
<button id="resetBtn" class="reset">复 位</button>
<button id="beginBtn" class="begin">开 始</button>
</footer>
</section> </body>
</html>

  css

@charset "utf-8";
body{ background-size: cover; background-color: #292929; }
*{ margin: 0px; padding: 0px; font-family: "微软雅黑"; outline: none;} section{width: 80%; margin: auto; margin-top: 200px; padding:5% ; border: 1px solid white; text-align: center; border-radius: 10px; background: rgba(255,255,255,0.6);}
section label{ display: block; line-height: 52px;}
section label input{ width:60% ; height: 30px; font-size: 24px; padding-left: 10px; color: blueviolet; border-radius: 30px;}
section footer {display: flex; text-align: center;}
section footer button{ margin: auto; width:120px ; height: 40px; font-size: 22px; color: white; border: 1px solid white; border-radius: 15px;}
section footer .reset{margin-right: 16px; background: #8b95d0;}
section footer .begin{ background: #52d8e8;}
section .showNum{ height: 70px; line-height: 70px; font-size: 70px; font-weight: bold; color: #363b3c; text-shadow: 0px 2px 4px gray;}

  js

$(document).ready(function(){
$(document.body).on('click', '#resetBtn', function(){
if(confirm("亲:您确定要复位吗?")){
window.location.reload();
}
}); var arr = [], mydsq = null; function RunNumFn(){
clearInterval(mydsq);
var i = 0;
mydsq = window.setInterval(function(){
i++;
if(i >= arr.length){
i = 0;
}
$('#showNum').html(arr[i]);
}, 8);
}; $(document.body).on('click', '#beginBtn', function(){
var begin = Number($('#begin').val()),
end = Number($('#end').val());
if(begin < 0){
alert("亲:起始值 不能小于 0 哦!");
return false;
}else if(begin > end){
alert("亲:起始值 不能大于 结束值哦!");
return false;
}
else if(end > 50000){
alert("亲:结束值 不能大于 50000 哦!");
return false;
}
else{
if($(this).text() == '开 始'){
document.getElementById("myMusic").play();
for(var i = begin; i <= end; i++){
arr.push(i);
} arr = arr.sort(function(){
return Math.random() - 0.5;
}) RunNumFn();
$(this).text('暂 停').css('background', '#8b95d0');
}else{
document.getElementById("myMusic").pause();
clearInterval(mydsq);
arr = [];
begin = 0;
$(this).text('开 始').css('background', '#52d8e8');
}
}
});
});

  效果:

jQuery随机抽取数字号代码的更多相关文章

  1. Lamda一行代码实现"36选7"随机自动选号

    南粤风采36选7是广东的一种彩票玩法.非常简单的从1-36个数字选7个. 今天在同事面前炫耀了一把,只用一行Lamda代码实现随机自动选号 Enumerable.Range(, ).Select(x ...

  2. 数据的随机抽取 及 jQuery补充效果(菜单、移动)

    一.数据的随机抽取 都见过那种考试题从很多题中随机抽取几道的试卷吧,现在就要做这样的一个例子:从数据库中随机抽取几条数据出来显示(例如:一百中随机挑选50条) 随机挑选是要有提交数据的,所以肯定是要有 ...

  3. 随手小代码——Python 从集合中随机抽取元素

    =================================版权声明================================= 版权声明:原创文章 谢绝转载  请通过右侧公告中的“联系邮 ...

  4. 【Python代码】随机抽取文件名列表NameList中的Name作为训练集

    #!/usr/bin/env python #coding=utf-8 #随机抽取一部分图片作为测试集 import random NameList=[]#存储所有图片名字 ''' NameListP ...

  5. SQL Server 随机数,随机区间,随机抽取数据rand(),floor(),ceiling(),round(),newid()函数等

    在查询分析器中执行:select rand(),可以看到结果会是类似于这样的随机小数:0.36361513486289558,像这样的小数在实际应用中用得不多,一般要取随机数都会取随机整数.那就看下面 ...

  6. jQuery弹出窗口完整代码

    jQuery弹出窗口完整代码 效果体验:http://keleyi.com/keleyi/phtml/jqtexiao/1.htm 1 <!DOCTYPE html PUBLIC "- ...

  7. 一个面试题的解答-----从500(Id不连续)道试题库里随机抽取20道题!

    做一个考试系统的项目,现在从试题库里面随机抽取20道题 比如我题库有500道题(ID不连续).题目出现了,如何解决呢,随机抽取! 1,我们先把500道题的id存进一个长度为500的数组. 2,实现代码 ...

  8. PHP之:随机抽取一个数&&随机函数

    撰写日期:2016-7-20 16:00:24 有5个数:1 4 7 9 6 用PHP实现随机抽取5个数中的其中一个 方法一: <?php $test = array(1,4,7,9,6);// ...

  9. 随机总数字里面选取随机数字进行随机排序案例(JAVA实现)

    随机总数字里面选取随机数字进行随机排序案例,案例如下: 代码code: package com.sec; import java.util.Arrays; import java.util.Scann ...

随机推荐

  1. IO,文件

    IO 1. 定义 >在内存中存在数据交换的操作认为是IO操作,比如和终端交互 ,和磁盘交互,和网络交互等 2. 程序分类 >* IO密集型程序:在程序执行中有大量IO操作,而cpu运算较少 ...

  2. linuxprobe培训第3节课笔记2019年7月7日

    linux常用命令: echo:在终端输出字符串或变量提取后的值 date:显示及设置系统的时间或日期 reboot:重启 poweroff:关机 wget:下载 ps:查看系统中的进程状态(常用参数 ...

  3. Python3.5-20190507-廖老师-自我笔记-迭代

    可以使用for x in 数据 的那么 这个数据就是可迭代对象. 通过计算生成下一个值的数据就是生成器 可以使用next(数据) 来计算出下一个值的数据就是迭代器(生成器属于迭代器) -------- ...

  4. OpenCV常用基本处理函数(7)图像金字塔和直方图

    高斯金字塔 高斯金字塔的顶部是通过将底部图像中的连续的行和列去除得到的.顶部图像中的每个像素值等于下一层图像中 5 个像素的高斯加权平均值. 这样操作一次一个 MxN 的图像就变成了一个 M/2xN/ ...

  5. POJ 3279 Fliptile (dfs+二进制)

    Description Farmer John knows that an intellectually satisfied cow is a happy cow who will give more ...

  6. [NOIP模拟测试38]题解

    来自达哥的问候…… A.金 显然本题的考察点在于高精而不是裴蜀定理 根据裴蜀定理易得答案为Yes当且仅当$gcd(n,m)=1$,那么考虑怎么在高精度下判互质. 如果$n,m$都能被2整除,那么显然不 ...

  7. ARMv8 架构与指令集.学习笔记

    目 录 第1章 ARMv8简介. 3 1.1基础认识. 3 1.2 相关专业名词解释. 3 第2章 Execution State 4 2.1 提供两种Execution State 4 2.2 决定 ...

  8. HTML5 开发技能图谱skill-map

    # HTML5 开发技能图谱![HTML5 脑图](https://github.com/TeamStuQ/skill-map/blob/master/data/designbyStuQ/png-HT ...

  9. JSP 取list的长度

    引入:<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> L ...

  10. 66、saleforce 的 approval process

    public class TestApproval { public void submitAndProcessApprovalRequest() { // Insert an account Lin ...