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

Some issues we should pay attention to when designing a web page

Web design, according to personal preferences and ...

Detailed explanation of memory management of MySQL InnoDB storage engine

Table of contents Storage Engine Memory Managemen...

Solution to IDEA not being able to connect to MySQL port number occupation

I can log in to MYSQL normally under the command ...

CSS positioning layout (position, positioning layout skills)

1. What is positioning? The position attribute in...

Implementation of MySQL master-slave status check

1. Check the synchronization status of A and B da...

MySQL 5.7.17 compressed package installation-free configuration process diagram

There are two versions of MySQL database manageme...

How to use Element in React project

This is my first time using the element framework...

TypeScript installation and use and basic data types

The first step is to install TypeScript globally ...

Web Design Experience: 5 Excellent Web Design Concepts Full Analysis (Pictures)

Unlike other types of design, web design has been ...

Detailed steps to delete environment variables in Linux

How to delete environment variables in Linux? Use...

Summary of mysqladmin daily management commands under MySQL (must read)

The usage format of the mysqladmin tool is: mysql...

CSS element hiding principle and display:none and visibility:hidden

1. CSS element hiding <br />In CSS, there ar...

Detailed explanation of MySQL precompilation function

This article shares the MySQL precompilation func...