本文實例為大家分享了js模擬支付寶密碼輸入框效果的具體代碼,供大家參考,具體內容如下
效果圖:

代碼:
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title></head><style> input{ width:60px; height:60px; font-size:40px; line-height: 60px; }</style><body><input type="password"/><input type="password"/><input type="password"/><input type="password"/></body><script src="jquery-1.11.3.js"></script><script> $(function(){ var ww=2222;//服務器驗證碼 $('input').eq(0).focus(); $('input').keyup(function(){ if($(this).val().length==1){ $(this).next().focus() } }) $('input').eq($('input').length-1).keyup(function(){ var valed='' for(var i=0;i<$('input').length;i++){ valed=valed+$('input').eq(i).val() } if(Number(valed)==ww){ alert('輸入正確') }else{ alert('輸入錯誤') } } ) })</script></html>以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。
新聞熱點
疑難解答