Can I dynamically set tabindex in JavaScript?

后端 未结 4 1344
再見小時候
再見小時候 2020-12-01 06:02

Is there any attribute like tab-index?

CONTEXT : I\'m making a section in a web form visible or invisible depending on some condition where I want to set the tab-ind

4条回答
  •  萌比男神i
    2020-12-01 06:35

    Using JQuery we can set tab index dynamically easily Try this code- set the tabindex and increment the variable

    $(function() {
        var tabindex = 1;
        $('input,select').each(function() {
            if (this.type != "hidden") {
                var $input = $(this);
                $input.attr("tabindex", tabindex);
                tabindex++;
            }
        });
    });
    

提交回复
热议问题