js实现可键盘控制的简单抽奖程序

js实现可键盘控制的简单抽奖程序,第1张

就看下吧

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Document</title>

</head>

<body>

<button id="buySelef">买一张(自选)</button>

<button id="buyRandom">买一张(机选)</button>

<button id="result">买一张(开奖)</button>

<div id='resultList'>

<span>结果</span>

</div>

</body>

</html>

<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>

<script>

window.Prize={LotteryResults:0 }

$("#buySelef").click(function(){

var num = Math.floor(Math.random() * (300 - 100) ) + 100

$("#resultList").append('<p>自选结果:'+num+'<p>')

})

$("#buyRandom").click(function(){

var num = Math.floor(Math.random() * (300 - 100) ) + 100

$("#resultList").append('<p>机选结果:'+num+'<p>')

})

$("#result").click(function(){

if(window.Prize.LotteryResults<=0)

{

var num = Math.floor(Math.random() * (300 - 100) ) + 100

window.Prize.LotteryResults=num

}

else{

var num = window.Prize.LotteryResults

}

$("#result").append('<p>开奖结果:'+num+'<p>')

})

</script>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12076094.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-20
下一篇 2023-05-20

发表评论

登录后才能评论

评论列表(0条)

保存