This article example shares the specific code of the JavaScript random roll call table for your reference. The specific content is as follows Effect: Code: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style> .box{ width:300px; height:200px; border:1px solid #ccc; /*position: absolute; left:0; right:0; top:0; bottom:0; margin: auto;*/ margin: 100px auto; text-align: center; } h1{ width:150px; height:60px; line-height: 60px; text-align: center; font-size: 30px; background-color: red; margin: 10px auto; } button{ width:100px; height:40px; background-color: dodgerblue; border:0; font-size: 24px; color:#fff; } </style> </head> <body> <div class="box"> <h1></h1> <button>Start</button> <button>Stop</button> </div> <script> var h1=document.getElementsByTagName('h1')[0]; var btn = document.getElementsByTagName("button"); var arr=["Su Chenxu","Zhang Zhiyang","Xiao Ming","Social Brother Kun","Yao","Jing Zhen","Jin Tao","Network Manager","Social Brother Chen","Zha Nan","Xue","Baby Man","Big Guy","Sleeping God","Long Ye","Ying Er","Northeast Baby","Ke Ke","Very Young Girl","Gou Dan","Gou Zi","Tian Jiao","Zhi Qiang","Jin Wei","Haitao","Sister Mai","Xin Feng","Sister Huan","Er Gou"]; var ind = ranFun(0,arr.length-1) h1.innerHTML=arr[ind]; var timer; btn[0].onclick=function(){ clearInterval(timer) timer = setInterval(function(){ h1.innerHTML=arr[ranFun(0,arr.length-1)] },100) } btn[1].onclick=function(){ clearInterval(timer) } function ranFun(a,b){ return Math.floor(Math.random()*(b-a+1)+a) } </script> </body> </html> The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: The main idea of dynamically setting routing permissions in Vue
>>: Sharing tips on using vue element and nuxt
When we write pages, we sometimes find that the C...
On the road to self-learning game development, th...
Sometimes the theme of a project cannot satisfy e...
<iframe src=”test.jsp” width=”100″ height=”50″...
Maybe you are using include files here, which is u...
When I was asked this question, I was ignorant an...
ssh is one of the two command line tools I use mo...
1. Installation environment Here is also a record...
1. Review The Buffer Pool will be initialized aft...
I recently upgraded a test server operating syste...
【Problem Analysis】 We can use the chown command. ...
Table of contents 1. some 2. every 3. find 1. som...
Preface In the previous article Detailed Explanat...
Table of contents 1. Introduction 2. Main text 2....
Preface Recently, during an interview, I was aske...