jQuery custom numeric lottery activity code
- 2021-06-28 08:36:19
- OfStack
This example shares the special effect code of jquery input digital random lottery for your reference, as follows
The code is as follows:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>jQuery Custom numeric lottery activity code - Why ask </title><base target="_blank" />
<script type="text/javascript" src="http://down.hovertree.com/jquery/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="http://hovertree.com/texiao/jquery/76/pjs_01.js"></script>
<style type="text/css">
#bigDiv {
width: 1080px;
margin: 0px auto; /*div Web page centered */
background-color: #494949;
color: #FFFFFF;
}
h1 {
text-align: center; /* Centered Text */
padding-top: 10px;
}
#first, #second, #third {
width: 360px;
height: 360px;
font-size: 150px;
line-height: 360px;
text-align: center;
float: left; /* Give Way 3 Box floats left */
}
#first {
background-color: #009BFF;
opacity: 0.9;
}
#second {
background-color: #007CCC;
}
#third {
background-color: #005388;
}
input {
font-size: 30px;
font-weight: 900;
}
#start {
margin-left: 40%;
margin-right: 5%;
}a{color:blue;}
</style>
</head>
<body>
<div id="bigDiv">
<h1> Player lucky draw </h1>
<div id="first"></div>
<div id="second"></div>
<div id="third"></div>
<input type="button" value=" start " id="start">
<input type="button" value=" Stop it " id="stop" disabled="disabled">
</div>
<div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';">
<p> For browsers: IE8 , 360 , FireFox , Chrome , Safari , Opera , Pride Tour, Sogou, Window of the World .</p>
<p> Source: <a href="http://hovertree.com"> Why ask </a>
<a href="http://hovertree.com/texiao/"> Special Effects Library </a>
<a href="http://hovertree.com/h/bjaf/07a7l2on.htm"> Code Description </a></p>
</div>
</body>
</html>
The js file code is as follows:
/**
* Created by Why ask Afternoon Sunlight on 2016/5/14.
*/
var ran = 0;
var range = 0;
var myNumber;
/* Encapsulate methods that generate random numbers */
function sjs(range) {
ran = Math.random() * range;//[0,range) Random number of
var result = parseInt(ran);// Convert Numbers to Integers
return result;
}
/* Encapsulate methods for displaying random numbers */
function showRandomNum() {
var figure = sjs(range);
$("#first").html(figure);
var figure2 = sjs(range);
$("#second").html(figure2);
var figure3 = sjs(range);
$("#third").html(figure3);
}
$(function () {
/* Click the Start button , Events generated */
$("#start").click(function () {
range = prompt(" Please enter the Random Number Range: ", "168");
if (range == null)//http://hovertree.com/h/bjaf/3siyd3x7.htm
{
return;
}
if (range == 0)
{
return;
}
if (isNaN(range))//http://hovertree.com/h/bjaf/9vhm2l4f.htm
{
alert(" please enter a number ");
return ;
}
/* Start tag disabled, stop tag enabled */
$("#start")[0].disabled = true;
$("#stop")[0].disabled = false;
if (range > 9999 || range<-999)
{
// by Why ask
$("#bigDiv div").css("font-size", "60px");//http://hovertree.com/h/bjaf/omgdn4mu.htm
//return;
}
myNumber = setInterval(showRandomNum, 50);// How long to run 1 Seconds, in milliseconds
});
/* Click the End button */
$("#stop").click(function () {
/* Start tag enabled, stop tag disabled */
$("#start")[0].disabled = false;
$("#stop")[0].disabled = true;
clearInterval(myNumber);
});
});
Above all, I hope it will be helpful for everyone to learn jquery program design.