Focus Next Element In Tab Index

后端 未结 20 2170
失恋的感觉
失恋的感觉 2020-11-27 03:06

I am trying to move the focus to the next element in the tab sequence based upon the current element which has focus. Thus far I have not turned up anything in my searches.<

20条回答
  •  伪装坚强ぢ
    2020-11-27 03:23

    Without jquery: First of all, on your tab-able elements, add class="tabable" this will let us select them later. (Do not forget the "." class selector prefix in the code below)

    var lastTabIndex = 10;
    function OnFocusOut()
    {
        var currentElement = $get(currentElementId); // ID set by OnFOcusIn
        var curIndex = currentElement.tabIndex; //get current elements tab index
        if(curIndex == lastTabIndex) { //if we are on the last tabindex, go back to the beginning
            curIndex = 0;
        }
        var tabbables = document.querySelectorAll(".tabable"); //get all tabable elements
        for(var i=0; i

提交回复
热议问题