站长资源网络编程

jquery——九宫格大转盘抽奖实例

整理:jimmy2026/8/2浏览2
简介一、用到的图片二、代码如下,重点是js部分jQuery九宫格大转盘抽奖</title</div> <div class="news_infos"><div id="MyContent"><p><strong> 一、用到的图片</strong></p> <p><a href="javascript:;" onclick="showimg('/UploadFiles/2021-04-02/201701160959095.jpg');"><img src="/UploadFiles/2021-04-02/201701160959095.jpg" alt="jquery——九宫格大转盘抽奖实例" onmousewheel="return bbimg(this)" onload="javascript:resizepic(this)" border="0"/></a><a href="javascript:;" onclick="showimg('//img.jbzj.com/file_images/article/201701/201701160959096.jpg');"><img src="//img.jbzj.com/file_images/article/201701/201701160959096.jpg" alt="jquery——九宫格大转盘抽奖实例" onmousewheel="return bbimg(this)" onload="javascript:resizepic(this)" border="0"/></a><a href="javascript:;" onclick="showimg('/UploadFiles/2021-04-02/201701160959097.jpg');"><img src="/UploadFiles/2021-04-02/201701160959097.jpg" alt="jquery——九宫格大转盘抽奖实例" onmousewheel="return bbimg(this)" onload="javascript:resizepic(this)" border="0"/></a><a href="javascript:;" onclick="showimg('//img.jbzj.com/file_images/article/201701/201701160959098.jpg');"><img src="//img.jbzj.com/file_images/article/201701/201701160959098.jpg" alt="jquery——九宫格大转盘抽奖实例" onmousewheel="return bbimg(this)" onload="javascript:resizepic(this)" border="0"/></a><a href="javascript:;" onclick="showimg('/UploadFiles/2021-04-02/201701160959099.jpg');"><img src="/UploadFiles/2021-04-02/201701160959099.jpg" alt="jquery——九宫格大转盘抽奖实例" onmousewheel="return bbimg(this)" onload="javascript:resizepic(this)" border="0"/></a><a href="javascript:;" onclick="showimg('//img.jbzj.com/file_images/article/201701/2017011609590910.jpg');"><img src="//img.jbzj.com/file_images/article/201701/2017011609590910.jpg" alt="jquery——九宫格大转盘抽奖实例" onmousewheel="return bbimg(this)" onload="javascript:resizepic(this)" border="0"/></a><a href="javascript:;" onclick="showimg('/UploadFiles/2021-04-02/2017011609590911.jpg');"><img src="/UploadFiles/2021-04-02/2017011609590911.jpg" alt="jquery——九宫格大转盘抽奖实例" onmousewheel="return bbimg(this)" onload="javascript:resizepic(this)" border="0"/></a><a href="javascript:;" onclick="showimg('//img.jbzj.com/file_images/article/201701/2017011609590912.jpg');"><img src="//img.jbzj.com/file_images/article/201701/2017011609590912.jpg" alt="jquery——九宫格大转盘抽奖实例" onmousewheel="return bbimg(this)" onload="javascript:resizepic(this)" border="0"/></a><a href="javascript:;" onclick="showimg('/UploadFiles/2021-04-02/2017011609590913.jpg');"><img src="/UploadFiles/2021-04-02/2017011609590913.jpg" alt="jquery——九宫格大转盘抽奖实例" onmousewheel="return bbimg(this)" onload="javascript:resizepic(this)" border="0"/></a></p> <p><strong>二、代码如下,重点是js部分</strong></p> <div class="htmlcode"> <pre class="brush:js;"> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>jQuery九宫格大转盘抽奖</title> <style> #lottery{width:570px;height:510px;margin:0px auto;border:4px solid #ba1809;} #lottery table{background-color:yellow;} #lottery table td{position:relative;width:190px;height:170px;text-align:center;color:#333;font-index:-999} #lottery table td img{display:block;width:190px;height:170px;} #lottery table td a{width:190px;height:170px;display:block;text-decoration:none;background:url(images/lottery1.jpg) no-repeat top center;} #lottery table td a:hover{background-image:url(images/lottery2.jpg);} #lottery table td.active .mask{display:block;} .mask{ width:100%; height:100%; position:absolute; left:0; top:0; background:url(images/mask.png) no-repeat; display:none; } </style> </head> <body class="keBody"> <!--效果html开始--> <div id="lottery"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td class="lottery-unit lottery-unit-0"><img src="/UploadFiles/2021-04-02/gift0.jpg"> <p>效果如下:</p> <p><a href="javascript:;" onclick="showimg('/UploadFiles/2021-04-02/2017011609590916.gif');"><img src="/UploadFiles/2021-04-02/2017011609590916.gif" alt="jquery——九宫格大转盘抽奖实例" onmousewheel="return bbimg(this)" onload="javascript:resizepic(this)" border="0"/></a></p> <p><strong>三、注意事项</strong></p> <p>1、抽奖过程说明</p> <p>上面只是前端展示的效果。中奖物品通过一个随机数生成。<br> </p> <div class="htmlcode"> <pre class="brush:js;"> var index = Math.random()*(lottery.count)|0;</pre> </div> <p>真正开发中中奖物品是通过向后端接口发送请求返回的。</p> <div class="htmlcode"> <pre class="brush:js;"> $("#lottery a").click(function(){ var islogin=checkLogin(); if(islogin){//已登录用户才能去抽奖 if (click) { return false; }else{ //向后端接口发请求返回中奖结果 var geturl="http://xxxxxx"+username+"&token="+token; $.ajax({  url:geturl, type:"GET", dataType:"json", async:false, success:function(data){ if(data.errorcode==0){ var rewardid=data["message"]["rewardid"]; var cardno=data["message"]["rewardCardNo"]; var passno=data["message"]["rewardCardPass"]; var prize=-1; var content=""; if(rewardid=="iphone6"){ lottery.prize=0; prize=0; content="一部iphone6手机"; $("#content1").html(content); }else if(rewardid=="PPTVKING"){ lottery.prize=1; prize=1; content="一部PPTV KING7s 3D影音手机"; $("#content1").html(content); /*... */ }else if(rewardid=="legao"){ lottery.prize=5; prize=5; content="一份乐高的玩具"; $("#content1").html(content); } lottery.speed=100; roll(); click=true; return false; }else{ /*错误处理*/ if(data.errorcode==3){ $("#novip").show(); }else{ $("#notime").show(); } } }/*function结束*/ });/*ajax结束*/ }/*else结束*/ } }); </pre> </div> <p>2、兼容性说明</p> <p>.mask开始如下,用的是rgba,但是IE8不兼容,改为使用png图片background:url(images/mask.png) no-repeat;<br> </p> <div class="htmlcode"> <pre class="brush:css;"> .mask { width: 100%; height: 100%; position: absolute; left: 0; top: 0; background-color: rgba(252,211,4,0.5); display: none }</pre> </div> <p>以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。</p></div> </div> </div> <div class="share"> </div> <div class="nextinfo"> <p>上一篇:<a href="/3g/1/102069.html" title="JavaScript日期选择功能示例">JavaScript日期选择功能示例</a></p> <p>下一篇:<a href="/3g/1/102071.html" title="jQuery的ajax中使用FormData实现页面无刷新上传功能">jQuery的ajax中使用FormData实现页面无刷新上传功能</a></p> </div> <div class="otherlink"> <h2>最新资源</h2> <ul> <li><a href="/3g/1/623703.html" title="群星《奔赴!万人现场 第2期》[FLAC/分轨]">群星《奔赴!万人现场 第2期》[FLAC/分轨]</a></li> <li><a href="/3g/1/623702.html" title="群星《奇妙浪一夏 (上海迪士尼度假区音乐">群星《奇妙浪一夏 (上海迪士尼度假区音乐</a></li> <li><a href="/3g/1/623701.html" title="群星《奇妙浪一夏 (上海迪士尼度假区音乐">群星《奇妙浪一夏 (上海迪士尼度假区音乐</a></li> <li><a href="/3g/1/623700.html" title="【古典音乐】詹姆斯·高威《季节》1993[WA">【古典音乐】詹姆斯·高威《季节》1993[WA</a></li> <li><a href="/3g/1/623699.html" title="贝拉芳蒂《卡里普索之王》SACD[WAV+CUE]">贝拉芳蒂《卡里普索之王》SACD[WAV+CUE]</a></li> <li><a href="/3g/1/623698.html" title="小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE">小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE</a></li> <li><a href="/3g/1/623697.html" title="群星《欢迎来到我身边 电影原声专辑》[32">群星《欢迎来到我身边 电影原声专辑》[32</a></li> <li><a href="/3g/1/623696.html" title="群星《欢迎来到我身边 电影原声专辑》[FL">群星《欢迎来到我身边 电影原声专辑》[FL</a></li> <li><a href="/3g/1/623695.html" title="雷婷《梦里蓝天HQⅡ》 2023头版限量编号低">雷婷《梦里蓝天HQⅡ》 2023头版限量编号低</a></li> <li><a href="/3g/1/623694.html" title="群星《2024好听新歌42》AI调整音效【WAV分">群星《2024好听新歌42》AI调整音效【WAV分</a></li> </ul> </div> </div> <div class="sidebar"> <div class="cloud"><h2 class="hometitle">一句话新闻</h2><a href="/3G/1/604690.html"><ul>Windows上运行安卓你用过了吗<br><br>在去年的5月23日,借助Intel Bridge Technology以及Intel Celadon两项技术的驱动,Intel为PC用户带来了Android On Windows(AOW)平台,并携手国内软件公司腾讯共同推出了腾讯应用宝电脑版,将Windows与安卓两大生态进行了融合,PC的使用体验随即被带入到了一个全新的阶段。</ul></a></div> </div> <div class="sidebar"> 友情链接:<a href="http://www.imxmx.com/" title="杰晶网络" target="_blank">杰晶网络</a> <a href="/" title="DDR爱好者之家" target="_blank">DDR爱好者之家</a> <a href="http://www.nqxw.com/" title="南强小屋" target="_blank">南强小屋</a> <a href="http://www.paidiu.com/" title="黑松山资源网" target="_blank">黑松山资源网</a> <a href="http://www.dyhadc.com/" title="白云城资源网" target="_blank">白云城资源网</a> <a href="/sitemap1.xml">站点地图</a> <a href="/sitemap.xml">SiteMap</a> </div> </article> <footer> <p>Design by <a href="http://m.ddrfans.com">DDR爱好者之家</a> <a href="http://m.ddrfans.com">http://m.ddrfans.com</a></p> </footer> <script src="/images3g/nav.js"></script> <script type="text/javascript"> jQuery.noConflict(); jQuery(function() { var elm = jQuery('#left_flow2'); var startPos = jQuery(elm).offset().top; jQuery.event.add(window, "scroll", function() { var p = jQuery(window).scrollTop(); jQuery(elm).css('position', ((p) > startPos) ? 'fixed' : ''); jQuery(elm).css('top', ((p) > startPos) ? '0' : ''); }); }); </script> </body> </html>