<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Генерация номера Казань</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<script>
function Number () {
var plusNumber = Math.floor(Math.random() * (9086543 - 1123456 + 1)) + 1123456;
var arrPreff = ["+7", "8", ""];
var randPreff = Math.floor(Math.random() * arrPreff.length);
var arrCode = ['900', '902', '903', '904', '905', '906', '908', '909', '917', '919', '927', '929', '937', '939', '950', '951', '952', '953', '958', '960', '962', '963', '965', '966', '967', '986', '987', '996', '999'];
var randCode = Math.floor(Math.random() * arrCode.length);
var resultNumber = arrPreff[randPreff]+arrCode[randCode]+plusNumber;
document.getElementsByTagName('p').innerHTML = resultNumber;
}
</script>
<div style="margin-top:15%;" class="container">
<p class="center-block text-center" style="text-align-center;">Тут будет номер</p>
<button class="btn center-block" onclick="Number()">Сгенерировать номер</button>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Генерация номера Казань</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<script>
function Number () {
var plusNumber = Math.floor(Math.random() * (9086543 - 1123456 + 1)) + 1123456;
var arrPreff = ["+7", "8", ""];
var randPreff = Math.floor(Math.random() * arrPreff.length);
var arrCode = ['900', '902', '903', '904', '905', '906', '908', '909', '917', '919', '927', '929', '937', '939', '950', '951', '952', '953', '958', '960', '962', '963', '965', '966', '967', '986', '987', '996', '999'];
var randCode = Math.floor(Math.random() * arrCode.length);
var resultNumber = arrPreff[randPreff]+arrCode[randCode]+plusNumber;
document.getElementById('phone-num').innerHTML = resultNumber;
}
</script>
<div style="margin-top:15%;" class="container">
<p id="phone-num" class="center-block text-center" style="text-align-center;">Тут будет номер</p>
<button class="btn center-block" onclick="Number()">Сгенерировать номер</button>
</div>
</body>
</html>
The getElementsByTagName() method returns a collection of all elements in the document with the specified tag name, as a NodeList object.
The NodeList object represents a collection of nodes. The nodes can be accessed by index numbers. The index starts at 0.