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

MySQL 8.0.11 Installation Guide for Mac

MAC installs mysql8.0, the specific contents are ...

How to use the concat function in mysql

As shown below: //Query the year and month of the...

Explanation of several ways to run Tomcat under Linux

Starting and shutting down Tomcat under Linux In ...

Detailed explanation of MYSQL log and backup and restore issues

This article shares MYSQL logs and backup and res...

Advantages and disadvantages of common MySQL storage engines

Table of contents View all storage engines InnoDB...

How to start a transaction in MySQL

Preface This article mainly introduces how to sta...

Centos7 implements sample code for restoring data based on MySQL logs

Introduction Binlog logs, that is, binary log fil...

Attributes and usage of ins and del tags

ins and del were introduced in HTML 4.0 to help au...

MySQL Optimization Solution Reference

Problems that may arise from optimization Optimiz...

Tools to convert static websites into RSS

<br /> This article is translated from allwe...

Vue Element-ui form validation rule implementation

Table of contents 1. Introduction 2. Entry mode o...

Web componentd component internal event callback and pain point analysis

Table of contents Written in front What exactly i...

Summary of some HTML code writing style suggestions

Omit the protocol of the resource file It is reco...