js implements random roll call

js implements random roll call

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:
  • A random roll call function implemented by javascript
  • A random roll call program using javascript
  • js implements random roll call system (example explanation)
  • JS implements random and sequential roll call in class
  • Code in js to use DOM to copy (clone) the specified node name data to a new XML file
  • js implements random roll call function
  • JS+CSS to achieve random roll call (example code)
  • Specific analysis of the needs of implementing random roll call in class with JavaScript
  • Detailed explanation of the example of random roll caller implemented in JavaScript
  • JavaScript implementation of random roll caller

<<:  Solution to the welcome to emergency mode message when booting CentOS7.4

>>:  MySQL 5.7.17 installation and configuration method graphic tutorial (windows10)

Recommend

CSS3 filter code to achieve gray or black mode on web pages

front end css3,filter can not only achieve the gr...

Mini Program to Implement Calculator Function

This article example shares the specific code of ...

Introduction to installing and configuring JDK under CentOS system

Table of contents Preface Check and uninstall Ope...

Vue detailed introductory notes

Table of contents 1. Introduction 2. Initial Vue ...

Tutorial on installing Elasticsearch 7.6.2 in Docker

Install Docker You have to install Docker, no fur...

Vue-Router installation process and principle detailed

Table of contents 1. Front-end routing implementa...

A colorful cat under Linux

Friends who have used the Linux system must have ...

Troubleshooting and solutions for MySQL auto-increment ID oversize problem

introduction Xiao A was writing code, and DBA Xia...

Detailed tutorial on deploying Django project using Docker on centos8

introduction In this article, we will introduce h...

JS generates unique ID methods: UUID and NanoID

Table of contents 1. Why NanoID is replacing UUID...

JavaScript flow control (branching)

Table of contents 1. Process Control 2. Sequentia...

How to install Linux online software gcc online

Linux online installation related commands: yum i...

MySQL query syntax summary

Preface: This article mainly introduces the query...