Jquery 实现input回车时跳转到下一个input元素


 
 
/**
 * 回车时跳转到下一个元素
 * @Author   HTL
 * @DateTime  2016-12-30T11:33:25+0800
 * @param     {[type]}                 $input [INPUT 元素列表]
 * @return    {[type]}                        [description]
 */
function keydown_to_tab($input){
  if(!$input) $input = $('input:text:not(:disabled)');
  $input.bind("keydown", function(e) {
    var n = $input.length;
    if (e.which == 13){
          e.preventDefault(); //Skip default behavior of the enter key
          var nextIndex = $input.index(this) + 1;
          if(nextIndex < n)
              $input[nextIndex].focus();
          else
              $input[nextIndex-1].blur();
    }
  });
}

 

参考:






免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM