小东西,需要的拿去
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> *{padding:0;margin: 0;} input{height: 10px;width: 10px;padding:10px;text-align: center;} </style> <script src="https://cdn.bootcss.com/jquery/3.3.0/jquery.js"></script> <script> $(function(){ $('input').on("input",function(){ if($(this).val()){ $(this).next().focus() }else{ $(this).prev().focus() } }) }) </script> </head> <body> <div> <input type="text" maxlength='1' minlength='1'> <input type="text" maxlength='1' minlength='1'> <input type="text" maxlength='1' minlength='1'> <input type="text" maxlength='1' minlength='1'> <input type="text" maxlength='1' minlength='1'> <input type="text" maxlength='1' minlength='1'> </div> </body> </html>