简体   繁体   English

我想在javascript中当前选项卡的最后一个元素上将一个选项卡切换到另一个选项卡

[英]I want to switch one tab to another tab on last element of current tab in javascript

i Write This code for that 我为此写这段代码

$(document).on('keydown','form input :nth-last-child(3)',function(e){
   var keyCode = e.keyCode || e.which;
   if (keyCode == 9) {
      var $parent=$('form').parents('.ui-tabs');
      if($parent.length>0) {
         var tabid=$parent.attr("id");
         var current= $( "#"+tabid ).tabs( "option", "active" );
         $( "#"+tabid ).tabs({ active: current +1 });
      }
   }
});

Here is a working demo with want you want to achieve if i understood it correctly: JS Bin 如果我正确理解,这是一个希望实现的工作演示: JS Bin

You should set the active tab options on the parent element on which you initialised jquery-ui tabs() , not on any particular #tab-{$id} . 您应该在初始化jquery-ui tabs()的父元素上而不是任何特定的#tab-{$id}上设置活动标签选项。

Below i also added the js code for it: 下面我还为此添加了js代码:

$(document).on('keydown','input',function(e){
  var keyCode = e.keyCode || e.which;

  if (keyCode == 9) {

    if($(this).is(':last-child')) {
      var current= $( '#tabs' ).tabs( "option", "active" );

      $('#tabs').tabs({ active: current +1 });
    }
  }
});

Let me know if you have trouble making it work. 如果您无法正常使用,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM