javascript - Move focus from one control to another control just pressing enter key by Jquery - Stack Overflow

suppose i have many html control in the page and all the control has a sequentially tab stop set.so if

suppose i have many html control in the page and all the control has a sequentially tab stop set.so if i press tab then focus move properly but i want to move focus just by pressing enter key instead of tab. so please tell me how could i programatically press tab when user will press enter key in my web page just by javascript or jquery. expecting small smaple code to achieve the effect i need.

thanks.

suppose i have many html control in the page and all the control has a sequentially tab stop set.so if i press tab then focus move properly but i want to move focus just by pressing enter key instead of tab. so please tell me how could i programatically press tab when user will press enter key in my web page just by javascript or jquery. expecting small smaple code to achieve the effect i need.

thanks.

Share Improve this question asked Jan 13, 2011 at 18:50 ThomasThomas 34.2k129 gold badges372 silver badges644 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4
$(':input').keypress(function(e){
  if(e.which == 13){
    ti = $(this).attr('tabindex') + 1;
    $('input[tabindex='+ti+']').focus();
    //try to use________ e.which = 9; return e.which;
  }else if(e.which == 9){
    e.preventDefault(); //or return false;
  }
});

Javascript way:

<body onkeydown="if(event.keyCode==13){event.keyCode=9; return event.keyCode;}">

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744966648a4603721.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信