码迷,mamicode.com
首页 > Web开发 > 详细

用JS实现的类似QQ密码的输入特效

时间:2015-04-04 13:34:20      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

<input ID="_PSD"></input>
<script>
function passwordText(ID,pd,mark){
mark=mark||"*"
var PSD=document.getElementById(ID)
var password=pd
var lh=PSD.value.length
setInterval(function(){
if(PSD.value.length!=lh){
if(PSD.value.length>lh)run(1)
else run(0)
lh=PSD.value.length
}
},1)
function run(n){
switch(n){
case 0:
password.length-=1
break
case 1:
password.push(PSD.value.charAt(PSD.value.length-1))
break
}
PSD.value=""
for(var i=0;i<password.length-1;i++)
PSD.value+=mark
if(password.length)
PSD.value+=password[password.length-1]
}
}
var password=[]
passwordText("_PSD",password,"*")
</script>

  

用JS实现的类似QQ密码的输入特效

标签:

原文地址:http://www.cnblogs.com/zckpdln/p/4392003.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!