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
Compared with ordinary programs, dynamic link lib...
animation-name animation name, can have multiple ...
Use of clip-path polygon The value is composed of...
Today I saw a case study on MySQL IN subquery opt...
Table of contents Preface Rolling principle accom...
1. The difference between TEXT and BLOB The only ...
This article mainly introduces the effect of div ...
This article uses examples to explain the princip...
The <link> tag defines the relationship bet...
Click here to return to the 123WORDPRESS.COM HTML ...
Table of contents 1. Differences between option A...
In HTML and CSS, we want to set the color of a bu...
Table of contents Isolate Data Columns Prefix Ind...
This article shares the installation and configur...
Ubuntu 16.04 installs the PHP7.0 environment by d...