This time I will bring you JS to implement the Ferris wheel lottery. What are the precautions for JS to implement the Ferris wheel lottery? The following is a practical case, let's take a look.
Rendering:


Picture material:

The code is as follows, copy and use:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | <!DOCTYPE html>
<html>
<head lang= "en" >
<meta charset= "UTF-8" >
<title>幸运抽奖页面</title>
<style>
*{
padding:0;
margin:0;
}
.login-box{
width:500px;
height:430px;
margin:100px auto;
<!-- 此处需要修改为自己的图片路径 -->
background: url(img/tx1.png) no-repeat;
box-shadow: 0 0 2px rgba(0,0,0,.5);
}
.login{
padding:5px;
border:0 none;
background: #0a88e1;
color: white;
font-size:12px;
text-align: center;
width:220px;
line-height: 20px;
margin-top:200px;
margin-left:120px;
}
</style>
</head>
<body>
<p class = "login-box" >
<input type= "button" value= "点击开始抽奖" class = "login" id= "luckbtn" onclick= "luck()" />
</p>
</body>
<script>
var no = prompt( "请输入您的四位会员卡号:" );
document.getElementById( "luckbtn" ).value =no+ "-欢迎你,点击开始抽奖" ;
function luck(){
var num = parseInt(Math.random()*10);
var baiwei = parseInt(no/100%10);
if (baiwei == num){
alert( "恭喜" +no+ ",您中奖了!" );
} else {
alert( "对不起," +no+ ",您没有中奖!" );
}
}
</script>
</html>
|
Copy after login
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
Detailed explanation of the use of JS event delegation
Detailed explanation of the use of computed in Vue.js
The above is the detailed content of JS implements Ferris wheel lottery. For more information, please follow other related articles on the PHP Chinese website!