This article shares the specific code of js to implement random roll call for your reference. The specific content is as follows Code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> div:nth-child(1) { width: 200px; height: 100px; background-color: burlywood; text-align: center; line-height: 100px; } div:nth-child(2) { width: 100px; height: 100px; background-color: pink; border-radius: 50%; text-align: center; line-height: 100px; } </style> </head> <body> <div>Liu Zhiyuan</div> <div>Begin</div> <script> var div = document.getElementsByTagName('div'); var btn = document.getElementsByTagName('button')[0]; username() function username() { var flag = false; var timerId = null; // console.log(div); : : : : : : : : : : : : : : : div[1].onclick = function() { if (flag) { clearInterval(timerId); div[1].innerHTML = 'Stop' flag = false; } else { timerId = setInterval(function() { var re = Math.floor(Math.random() * arr.length); console.log(re); div[0].innerHTML = arr[re]; }, 60); div[1].innerHTML = 'start' flag = true; } } } </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:
|
<<: Solution to the welcome to emergency mode message when booting CentOS7.4
>>: MySQL 5.7.17 installation and configuration method graphic tutorial (windows10)
front end css3,filter can not only achieve the gr...
In web front-end development, it is inevitable to ...
This article example shares the specific code of ...
Table of contents Preface Check and uninstall Ope...
Table of contents 1. Introduction 2. Initial Vue ...
Install Docker You have to install Docker, no fur...
Table of contents 1. Front-end routing implementa...
Friends who have used the Linux system must have ...
introduction Xiao A was writing code, and DBA Xia...
introduction In this article, we will introduce h...
It's embarrassing to say that I had to search ...
Table of contents 1. Why NanoID is replacing UUID...
Table of contents 1. Process Control 2. Sequentia...
Linux online installation related commands: yum i...
Preface: This article mainly introduces the query...