「jQuery入門」next().focus()でフォーカスを移動するサンプル

2021年2月19日

書式
$(this).next().focus();
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$('input[name^="userId"]').keyup(function() {
//最大文字数
var maxLen = $(this).attr('maxlength');
//入力文字数
var valLen = $(this).val().length;
if(valLen >= maxLen) {
$(this).next().focus();
}
});
$('input[name^="userId"]').keyup(function() { //最大文字数 var maxLen = $(this).attr('maxlength'); //入力文字数 var valLen = $(this).val().length; if(valLen >= maxLen) { $(this).next().focus(); } });
$('input[name^="userId"]').keyup(function() {
   //最大文字数
   var maxLen = $(this).attr('maxlength');
   //入力文字数
   var  valLen = $(this).val().length;
   if(valLen >= maxLen) {
      $(this).next().focus();
    }
 });

 

jQuery

Posted by arkgame