Use JS to implement a random roll call system for your reference. The specific content is as follows Ten minutes before every class, the teacher would ask us to answer questions, but every time he would call out the student numbers, and it seemed like I would win every time. So I directly suggested to the teacher, "Teacher, let me use JS to help you write a random roll call system!" This way I won't be picked every time, haha First look at the effect: The code is as follows: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <button id="box1">Start</button> <button id="box2">End</button> <span id="box">Tom</span> <script> //Get the element in the page var btn1 = document.getElementById('box1'); var btn2 = document.getElementById('box2'); var span = document.getElementById('box'); var names = ['Tom', 'Jack', 'Lucy', 'Peter', 'Mark', 'Min', 'Liu', 'Rani']; var timer; btn1.onclick = function() { window.clearInterval(timer); timer = window.setInterval(countName, 100); }; btn2.onclick = function() { window.clearInterval(timer); }; function countName() { var index = parseInt(Math.random() * names.length); span.innerHTML = names[index]; } </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:
|
<<: How to add ansible service in alpine image
In MySQL, there is a function called "group_...
This tutorial shares the detailed steps of instal...
1. Data desensitization explanation In daily deve...
Note: sg11 Our company only supports self-install...
Here, clever use of CSS techniques allows you to g...
MySQL handles duplicate data Some MySQL tables ma...
Preface mysqlslap is a diagnostic program designe...
Preface Let me explain here first. Many people on...
Linux builds NFS server In order to achieve data ...
Introduction Based on docker container and docker...
Table of contents Preface On-site investigation C...
The centos8 distribution is released through the ...
I have been learning porters recently. I feel lik...
Table of contents 1. Master-slave synchronization...
CSS has two pseudo-classes that are not commonly ...