纯html模仿支付宝or微信 支付密码输入

exp 图片示例

源码 直接复制源码保存html 运行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<!DOCTYPE html>
<html>
<head>
<title>模拟密码输入框效果-练小习-caihong.cc</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0" />
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<style>
*{
margin: 0;
padding: 0;
list-style: none;
}
body{
-webkit-tap-highlight-color: transparent;
font-family: "Helvetica Neue",Helvetica,STHeiTi,Arial;
font-size: 12px;
background-color: #f0f0f0;
}
h1{
font-size: 14px;
font-weight: 400;
text-align: center;
color: #ff6600;
padding: 0 0 20px;
}
.box{
margin: 20px;
padding: 20px;
background: #fff;
text-align: center;
}
input{
margin: 0;
padding: 0;
width: 1px;
opacity: 0;
height: 1px;
border: none;
}
label{
display: block;
}
ul{
border: 1px solid #c8c8c8;
font-size: 0;
display: inline-block;
position: relative;
font-size: 0;
}
ul li{
display: inline-block;
width: 35px;
height: 35px;
font-size: 24px;
font-weight: 700;
text-align: center;
line-height: 40px;
border-left: 1px solid #e6e6e6;
vertical-align: middle;
overflow: hidden;
}
ul li:first-child {
border-left: none;
}
a{
height: 30px;
padding: 0 20px;
border: 1px solid #0064b6;
border-radius: 3px;
background: #0071ce;
color: #fff;
font-size: 14px;
line-height: 30px;
text-align: center;
display: inline-block;
outline: 0 none;
text-decoration: none;
margin-top: 40px;
}
.show{
padding: 20px;
}
em{
font-style: normal;
color: #ff6600
}
</style>
</head>
<body>
<div class="box">
<h1>模拟密码输入框</h1>
<label for="ipt">
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</label>
<input type="tel" id="ipt" maxlength="6">
<a href="javascript:void(0);">确认</a>
<div class="show">您输入的密码:<em></em></div>
</div>
<script>
$(document).keyup(function (e){
var numLen = 6;
var pw = $('input').val();
var list = $('li');
$('em').text($('input').val());
for(var i=0; i<numLen; i++){
if(pw[i]){
$(list[i]).text('*');
}else{
$(list[i]).text('');
}
}
});
</script>
</body>
</html>