国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

JavaScript實現PC端四格密碼輸入框功能

2024-05-06 15:44:38
字體:
來源:轉載
供稿:網友

本文實例為大家分享了JavaScript實現PC端四格密碼輸入框的具體代碼,供大家參考,具體內容如下

html代碼如下

比較簡潔的一個demo

<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>四個密碼輸入框</title> <script type="text/javascript" src="jquery.min.js" ></script> </head> <style type="text/css"> input{  width:40px;  height:40px;  text-align: center;  font-size:22px; } </style> <body> 支付密碼 <input type="password" name="pwd1" maxlength="1"/> <input type="password" name="pwd2" maxlength="1"/> <input type="password" name="pwd3" maxlength="1"/> <input type="password" name="pwd4" maxlength="1"/> </body> <script> //必須引入jquery才可以用 //1:當輸入框1輸入1個字符后,自動切換光標到輸入框2 $(document).ready(function(){  $("[name='pwd1']").bind("input",function(){  if($(this).val().length==1){   $("[name='pwd2']").focus();  }  })  $("[name='pwd2']").bind("input",function(){  if($(this).val().length==1){   $("[name='pwd3']").focus();  }else if($(this).val().length==0){   $("[name='pwd1']").focus();  }  })  $("[name='pwd3']").bind("input",function(){  if($(this).val().length==1){   $("[name='pwd4']").focus();  }else if($(this).val().length==0){   $("[name='pwd2']").focus();  }  })  $("[name='pwd4']").bind("input",function(){  if($(this).val().length==0){   $("[name='pwd3']").focus();  }     }) }) </script></html>

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持錯新站長站。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 阿拉善右旗| 都江堰市| 芜湖县| 南昌县| 闽侯县| 虞城县| 百色市| 麻城市| 克拉玛依市| 万载县| 许昌县| 嵊州市| 微博| 贵德县| 香港 | 皮山县| 陈巴尔虎旗| 治多县| 金寨县| 万盛区| 隆回县| 绵阳市| 中阳县| 耒阳市| 上杭县| 凭祥市| 会理县| 民县| 福鼎市| 固原市| 綦江县| 宝丰县| 肇源县| 东安县| 鄂托克前旗| 双桥区| 张家界市| 库伦旗| 密山市| 丰原市| 广宗县|