随机代码生成器 - WebCat
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>WebCat</title>
<script src="js/jquery.min.js"></script>
<script src="js/wc-3.0.6.min.js"></script>
</head>
<body>
<h1 id="title">Hello world</h1>
<p id="p1">工程创建成功!</p>
<button id="btn">Click me</button>
<script>
const options = ['1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
let selected = [];
while(selected.length < 12) {
let randomIndex = Math.floor(Math.random() * options.length);
let randomChar = options[randomIndex];
if(selected.indexOf(randomChar) === -1) {
selected.push(randomChar);
}
}
p1.onclick=function(){
$("#title").text(selected.join(""));
}
btn.onclick=function(){
selected = [];
while(selected.length < 12) {
let randomIndex = Math.floor(Math.random() * options.length);
let randomChar = options[randomIndex];
if(selected.indexOf(randomChar) === -1) {
selected.push(randomChar);
}
}
$("#title").text("Hello world");
}
</script>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/obwQ 著作权归作者所有。请勿转载和采集!