用jQuery实现抽奖程序

2020-05-29 07:27:29易采站长站整理

本文实例为大家分享了jQuery实现抽奖程序的具体代码,供大家参考,具体内容如下

1. 主要需求

实现一个抽奖功能。
点击开始按钮后,开始按钮禁用,停止按钮取消禁用,小图片实现快速切换显示。
点击停止按钮后,停止按钮禁用,开始按钮取消禁用,小图片停止切换,将小图片在大图片位置显示。
小图片实现快速切换显示。
点击停止按钮后,淡入淡出选中图。

2. 素材页面


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>抽奖程序</title>
<script type="text/javascript" src="../js/jquery-1.11.1.js"></script>

<style type="text/css">
#small {
border: 1px solid blueviolet;
width: 75px;
height: 75px;
margin-bottom: 20px;
}

#smallPhoto {
width: 75px;
height: 75px;
}

#big {
border: 2px solid orangered;
width: 500px;
height: 500px;
position: absolute;
left: 300px;
top: 10px
}

#bigPhoto {
width: 500px;
height: 500px;
}

#btnStart {
width: 100px;
height: 100px;
font-size: 22px;
}

#btnStop {
width: 100px;
height: 100px;
font-size: 22px;
}
</style>
</head>

<body>
<!-- 小像框 -->
<div id="small">
<img id="smallPhoto" src="../img/man00.png"/>
</div>

<!-- 大像框 -->
<div id="big">
<img id="bigPhoto" src="../img/begin.jpg" />
</div>
<input id="btnStart" type="button" value="点击开始"/>
<input id="btnStop" type="button" value="点击停止"/ disabled>

<script type="text/javascript">

</script>
</body>
</html>

3. 代码实现


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>抽奖程序</title>
<script type="text/javascript" src="../js/jquery-1.11.3.js"></script>

<style type="text/css">
#small {
border: 1px solid blueviolet;
width: 75px;
height: 75px;
margin-bottom: 20px;
}

#smallPhoto {
width: 75px;
height: 75px;
}

#big {
border: 2px solid orangered;
width: 500px;
height: 500px;
position: absolute;
left: 300px;
top: 10px
}

#bigPhoto {
width: 500px;
height: 500px;
}

#btnStart {
width: 100px;
height: 100px;
font-size: 22px;
}

#btnStop {