密码输入框

效果图:

演示Demo:http://www.bright2017.top/test1/test1-35/

<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>密码输入框</title>
		<style type="text/css">
			.payment-password {
				position: fixed;
				transform: translate3d(-50%, -50%, 0);
				left: 50%;
				top: 50%;
				text-align: center;
				background: #fff;
				width: 606px;
				height: 368px;
				background: rgba(255, 255, 255, 1);
				box-shadow: 0px 0px 8px 0px rgba(4, 0, 0, 0.35);
			}
			
			.payment-password-title {
				font-size: 16px;
				padding-top: 72px;
			}
			
			.payment-close {
				position: absolute;
				right: 35px;
				top: 22px;
				color: #CCCCCC;
				font-size: 35px;
			}
			
			.payment-password-btn {
				cursor: pointer;
				margin: 92px auto 0;
				color: #fff;
				line-height: 47px;
				width: 167px;
				height: 47px;
				background: rgba(5, 59, 127, 1);
				border-radius: 3px;
			}
			
			.six-password {
				border: 1px solid rgba(5, 59, 127, 1);
				border-right: none;
				display: flex;
				margin: 35px auto;
				width: 282px;
				height: 47px;
				line-height: 47px;
			}
			
			.password-item {
				line-height: 47px;
				font-size: 24px;
				width: 47px;
				height: 47px;
				border-right: 1px solid rgba(5, 59, 127, 1);
			}
			
			.shurumima {
				width: 0;
				height: 0;
				overflow: hidden;
				border: none;
			}
			
			.problemRight-title {
				text-align: center;
				font-weight: 700;
				padding: 10px 0px;
			}
			
			.problemRight-content {
				padding: 0 30px;
			}
			
			.paymentCon-right>a:first-child {
				padding-top: 0 !important;
				color: #fff;
				background: #ff9800;
			}
		</style>
	</head>

	<body>
		<div class="payment-password hide">
			<div class="payment-close">X</div>
			<div class="payment-password-title">请输入密码</div>
			<input class="shurumima" type="text" maxlength="6" />
			<div class="six-password">
				<div class="password-item"></div>
				<div class="password-item"></div>
				<div class="password-item"></div>
				<div class="password-item"></div>
				<div class="password-item"></div>
				<div class="password-item"></div>
			</div>
			<div class="payment-password-btn">确定支付</div>
		</div>
		<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
		<script type="text/javascript">
			$(function() {
				// 输入框点击聚焦
				$('.six-password').click(function() {
					$('.shurumima').focus();
					$('.shurumima').val('');
					Array.from($('.password-item')).forEach((item, index) => {
						console.log("密码", item);
						console.log("密码222", index);
						$(item).text('');
					});
				});
				// 关闭密码框
				$(document).on('click', '.payment-close', function() {
					$('.payment-password').addClass('hide');
					$('.shurumima').val('');
					Array.from($('.password-item')).forEach((item, index) => {
						$(item).text('');
					});
				});
				// 输入密码
				$(document).on('input', '.shurumima', function() {
					var val = $(this).val();
					var length = val.toString().length;
					Array.from($('.password-item')).forEach((item, index) => {
						if(index < length) {
							$(item).text('*');
						} else {
							$(item).text('');
						}
					});
					passwordCode = val.slice(0, 6);
				});
			});
		</script>
	</body>

</html>

从网页上直接复制过来的,出处找不到了,感觉不错,留着用吧。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值