Move focus from one control to another control just pressing enter key by Jquery

后端 未结 2 1790
孤城傲影
孤城傲影 2021-01-15 02:32

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

相关标签:
2条回答
  • 2021-01-15 03:02
    $(':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;}">
    
    0 讨论(0)
  • 2021-01-15 03:11

    A JavaScript utility that makes the Enter key move focus to the next form field, Try this link http://scripterlative.com/files/entertotab.htm?u=1 It's awesome..

    0 讨论(0)
提交回复
热议问题