亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

大佬們,我這個抽取人的東西想要抽中到的人直接停下來后,直接顯示到下面的圓圈內出錯這改怎么改啊

大佬們,我這個抽取人的東西想要抽中到的人直接停下來后,直接顯示到下面的圓圈內出錯這改怎么改啊

大佬們我的想法是在下面建四個.xia的img 先不設置src,先設個變量zons為0,然后獲取img的class $(“.xia:eq(zons)") 然后再用attr來改src設置為隨機數抽到的數組元素,再之后設置zons變量初始化為0 自增到3也就是.xia的下標一個一個來設置四個img的圖片路徑,可下面這樣報錯怎么辦啊,大佬求助QWQ<!DOCTYPE html><html> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>jquery隨機抽獎 </title> <head> <script type="text/javascript" src="jq/jquery-3.1.1.js"></script></script> <script type="text/javascript"> $(function(){ var alldata = new Array("img/2.jpg","img/3.jpg","img/4.jpg","img/5.jpg"); var show = $("#show") var start = $("#start"); var btn = $("#btn"); var randomVal; var nums = ?4; var zons = 0; var zon = $("#zon") var open = false; zon.append(nums); function change(){ var num = alldata.length - 1; randomVal = Math.round(Math.random() * num); var prizeName = alldata[randomVal]; start.attr("src",prizeName); } function run(){ if(!open){ timer=setInterval(change,30); btn.removeClass('start').addClass('stop').text('停止'); show.animate({bottom:"50px"},300);? ? ? ? ? ? ? ? show.animate({bottom:"0px"},300);? ? ? ? ? ? ? ? if (nums<1) {? ? ? ? ? ? ? ? btn.removeClass('start').addClass('end').text('謝謝');? ? ? ? ? ? ? ? start.attr("src","img/6.jpg");? ? ? ? ? ? ? ? } open = true; }else{ clearInterval(timer); btn.removeClass('stop').addClass('start').text('開始抽獎'); show.animate({bottom:"50px"},300);? ? ? ? ? ? ? ? show.animate({bottom:"0px"},300);? ? ? ? ? ? ? ? if (nums<2) {? ? ? ? ? ? ? ? btn.removeClass('stop').addClass('end').text('謝謝');? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? goon();? ? ? ? ? ? ? ? select(); open = false; } } function goon() { ? ?nums--;? ? ? ? ? ? ? ? if (nums<0) {? ? ? ? ? ? ? ? nums=0;? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ??? ? ? ? ? ? ? ??? ? ? ? ? ? ? ? zon.html("總計"+":"+nums);? ? ? ? ? ? ? ? alldata.splice(randomVal,1); } function ?select() { ? zons++; ? if (zons>3) { ? zons=3; ? } ? console.log(zons);? ? ? ? ? ? ? ?$(".xia:eq(zons)").attr("src",prizeName); } btn.click(function(){run();}) }) </script> <style> body{ background:#fff;} .main{ width: 1000px; height: 800px; border: 1px solid red; margin: 0 auto; } .wrap{ width:300px; margin:100px auto; font-family:"微軟雅黑"; border: 1px solid red;} .show{ width:300px; height:300px; background-color:#ff3300; line-height:300px; text-align:center; color:#fff; font-size:28px; -moz-border-radius:150px; -webkit-border-radius:150px; border-radius:150px; background-image: -webkit-gradient(linear,0% 0%, 0% 100%, from(#FF9600), to(#F84000), color-stop(0.5,#fb6c00)); -moz-box-shadow:2px 2px 10px #BBBBBB; -webkit-box-shadow:2px 2px 10px #BBBBBB; box-shadow:2px 2px 10px #BBBBBB;overflow: hidden; position: relative;} .btn a{ display:block; width:120px; height:50px; margin:30px auto; text-align:center; line-height:50px; text-decoration:none; color:#fff; -moz-border-radius:25px; -webkit-border-radius:25px; border-radius:25px;} .btn a.start{ background:#80b600;} .btn a.start:hover{ background:#75a700;} .btn a.stop{ background:#00a2ff;} .btn a.stop:hover{ background:#008bdb;} .btn a.end{background: orange;} .bottom{border:1px solid red; width: 800px; height: 100px; margin: 100px;} .xia{-moz-border-radius:150px; -webkit-border-radius:150px; border-radius:150px; border: 1px solid red; margin-left: 80px; overflow: hidden;} </style> </head> <body> <div class="main"> <div class="wrap"> <div class="show" id="show"><img id="start" src="img/1.jpg" width="300" height="300"></div> <div class="btn"> <a href="javascript:void(0)" class="start" id="btn">開始抽獎</a> </div> <div style="text-align:center;clear:both">? ? ? ? ? <p id="zon">總計:</p>? ? ? ? </div> </div> <div class="bottom"><img class="xia" src="" width="100" height="100"><img ?class="xia" src="" width="100" height="100"><img class="xia" src="" width="100" height="100"><img class="xia" src="" width="100" height="100"></div> </div> </body></html>
查看完整描述

1 回答

?
無節操司機

TA貢獻1條經驗 獲得超0個贊

有人嗎

查看完整回答
反對 回復 2017-02-16
  • 1 回答
  • 0 關注
  • 1417 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號