简单使用
使用的是String对象的formCharCode()方法转换的
var num2 = Math.floor(Math.random()*26+97);
var st1 = String.fromCharCode(num2)
document.write(st1)
案列
四位大小写字母和数字组成的验证码
效果
点击后
再次点击
完整代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
body{
/* background-color: #00FFFF; */
}
.content{
width: 300px;
height: 400px;
margin: 0 auto;
}
#box{
/* background-image: linear-gradient(to right, #fa709a 0%, #fee140 100%); */
width: 100%;
height: 300px;
margin: 0 auto;
margin-top: 200px;
position: