Home > Web Front-end > JS Tutorial > body text

How to implement random naming of an array

一个新手
Release: 2017-09-23 09:52:48
Original
2097 people have browsed it

var random = parseInt(Math.random()*arr.length);
for(var i = 0; i < lis.length; i++) {
lis[i].className = "";
}
lis[random].className = "style";
Copy after login

*(Find the object, multiple lis, traverse it, clear everyone, the number of i in lis[i] is assigned randomly)

About exclusivity, remove the empty space in the front and assign the value in the back , the attributes must be exactly the same, otherwise it will be useless! ! !

Exclusive

1The first layer is used to control all input objects

2Click one of the inputs to trigger an event

3Kill everyone for ""

4Resurrect myself this.""

Assume that all selections are true, and the top one is true;

input[i]The selections after traversal are One false, all of them are false, there is no

in the above

The above is the detailed content of How to implement random naming of an array. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template