<input type = "number"id = "qaz"value = "" > <button onclick = "fu()"id = "yhn" > 提交 < /button> <input type = "text"value = "0"id = "rfv"style = "display: none;"readonly ="readonly" > <button id = "edc"style = "display: none;" > 抽奖 < /button>
加 display:none 让他们两个隐藏起来,达到一定条件再显示出来
let qaz = document.getElementById("qaz"); let edc = document.getElementById("edc"); let rfv = document.getElementById("rfv"); let yhn = document.getElementById("yhn"); edc.onclick = function() { rfv.value++; } function fu() { if (qaz.value <= 17) { alert('未成年'); } else if (qaz.value >= 18 && qaz.value < 40) { alert('青少年'); } else if (qaz.value >= 40 && qaz.value < 60) { alert('中年'); } else if (qaz.value >= 60 && qaz.value <= 100) { alert('低保户'); edc.style.display = "inline-block"; rfv.style.display = "inline-block"; setTimeout(function() { if (rfv.value > 20 && rfv.value < 30) { alert('抽奖成功'); edc.style.display = "none"; rfv.style.display = "none"; qaz.style.display = "none"; yhn.style.display = "none"; } else if (rfv.value >= 30 && rfv.value < 40) { alert('B'); edc.style.display = "none"; rfv.style.display = "none"; qaz.style.display = "none"; yhn.style.display = "none"; } else if (rfv.value >= 40 && rfv.value <= 50) { alert('A'); edc.style.display = "none"; rfv.style.display = "none"; qaz.style.display = "none"; yhn.style.display = "none"; } else if (rfv.value > 50) { alert('SSS'); edc.style.display = "none"; rfv.style.display = "none"; qaz.style.display = "none"; yhn.style.display = "none"; } else { alert('失败'); edc.style.display = "none"; rfv.style.display = "none"; qaz.style.display = "none"; yhn.style.display = "none"; } }, 5000) } }
获取过来标签,判断value值可不可以抽奖可以显示,不可以弹出alert;
获取过来标签,加上点击事件,使value的值加加
设置一个定时器 几秒后执行(以毫秒为单位1秒等于一千毫秒),执行的什么
判断达不达标,达标怎么样,不达标怎么样