批量生成手机号

#list li { width: 7.5em;display: inline-block;}
开始

当前个数:

// /^1[34578]\d{9}$/.test(nuM) var totalObj = document.getElementById(“total”); var inputObj = document.getElementById(“numbers”); var listObj = document.getElementById(“list”); function phoneNumber() { var first = “1”; var secondArr = [“3”, “4”, “5”, “7”, “8”]; var second = secondArr[String(Math.floor(Math.random() * secondArr.length))]; var lastArr = []; for (var i = 0; i < 9; i++) { var num = Math.floor(Math.random() * 10); lastArr.unshift(num); }; var last = lastArr.join(“”); var phone = first + second + last; var li = document.createElement(“li”); li.innerHTML = phone; listObj.appendChild(li); return phone; } //数组去重 function getArray(a) { var hash = {}, len = a.length, result = []; for (var i = 0; i < len; i++) { if (!hash[a[i]]) { hash[a[i]] = true; result.push(a[i]); } }; return result; } var phoneArr = []; var timer; var isStart = false; function startFun() { if (!isStart) { isStart = true listObj.innerHTML = “”; timer = setInterval(function () { phoneArr.push(phoneNumber()); phoneArr = getArray(phoneArr); totalObj.innerHTML = phoneArr.length; if (phoneArr.length >= inputObj.value) { clearInterval(timer); isStart = false; listObj.innerHTML = “”; for (var i = 0; i < phoneArr.length; i++) { var li = document.createElement(“li”); li.innerHTML = phoneArr[i]; listObj.appendChild(li); } console.log(phoneArr); phoneArr = []; }; }); } else { alert(“正在生成号码!”); } }


批量生成手机号
http://example.com/2017-11-06 批量生成手机号/
作者
csorz
发布于
2017年11月6日
许可协议