JS generate random number can use JavaScript math.random () built-in functions, here is a good example, you can try to operate under
The JavaScript math.random () built-in function random return value returns a pseudo random number between 0 and 1, possibly 0, but always less than 1,[0,1) random function Example//returns the random number document.write (Math.rando m ()); Returns a random number of 10-20 document.write (Math.random () * (20-10) +10); Returns the formula for the specified range of random numbers (m-n) document.write (Math.random () * (N-M) +m); Based on time, also can generate random number code as follows: Var now=new Date (); var number = Now.getseconds (); This will result in a 0 to 59 integer based on the current time. var now=new Date (); var number = Now.getseconds ()%43; This will result in a 0 to 42 integer based on the current time.