<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> input{ text-align: center; width: 200px; height: 100px; margin: 0 auto; } button{ margin-top: 15px; margin-left: 15px; } </style> </head> <body> <input type="text" value="张三"><br/> <button>开始</button> <button>停止</button><br/> <script> var ss=confirm("确认"); if(ss){ console.log("1") }else{ console.log("0") } var sm=prompt("请输入薪资"); if(sm<2000){ console.log("屌丝"); }else if(sm>6000&&sm<20000){ console.log("土豪"); }else if(sm>2000&&sm<6000){ console.log("一般人"); } var input=document.getElementsByTagName("input")[0]; var start=document.getElementsByTagName("button")[0]; var stop=document.getElementsByTagName("button")[1]; var string="沈雪松,沈晖然,郭太安,宋佳伟,赵俊超,郑鹏飞,焦腾朝"; var arr=string.split(","); var timer; start.οnclick=function () { clearInterval(timer); timer=setInterval(function () { var ss=parseInt(Math.random()*arr.length); input.value=arr[ss]; },500); stop.οnclick=function () { clearInterval(timer); } } </script> </body> </html>
H5的confirm(对话框)、prompt(输入框)、setInterval(循坏定时器)
最新推荐文章于 2022-03-16 20:51:59 发布