Home > Web Front-end > JS Tutorial > js randomly generates 6-digit random numbers

js randomly generates 6-digit random numbers

php中世界最好的语言
Release: 2018-03-17 13:47:10
Original
10733 people have browsed it

We often use random numbers when making web pages or small programs. The author has compiled a very simple JS program to generate random numbers. Let’s learn together.

Let’s take a look at the renderings of this source code first

You can use it flexibly, we will share the specific JS code with you:

<!doctype html> 
<html> 
<head> 
<meta charset="utf-8"> 
<title>Document</title> 
<style> 
  #count{ 
    font-size: 20px; 
    color: green; 
    width: 400px; 
    height: 30px; 
    border: 1px solid black; 
    margin: auto; 
    line-height: 30px; 
    text-align: center; 
  } 
  </style> 
</head> 
<body> 
  <p id="count"></p> 
  <script> 
  //产生随机数 
function count (){ 
  var i=Math.random()*(999999-100000)+100000; 
  var j=parseInt(i,10); 
  j="100000-999999随机产生:"+j; 
  document.getElementById("count").innerHTML= j; 
} 
setInterval("count()",100); 
  </script> 
</body> 
</html>
Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

D3.js draws dynamic progress bar

##ngrok+express for local environment WeChat interface debugging

What should I do if the dynamically loaded data slide always fails?

The above is the detailed content of js randomly generates 6-digit random numbers. 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