Prevent tabstop on A element (anchor link) in HTML

后端 未结 5 725
北荒
北荒 2020-11-29 05:54
相关标签:
5条回答
  • 2020-11-29 06:09

    Modern, HTML5 compliant, browsers support the [tabindex] attribute, where a value of -1 will prevent the element from being tabbed to.

    If the value is a negative integer
    The user agent must allow the element to be focused, but should not allow the element to be reached using sequential focus navigation.

    0 讨论(0)
  • 2020-11-29 06:20

    I think you could do this by javascript, you override the window.onkeypress or onkeydown, trap the tab button, and set the focus at the desired order.

    0 讨论(0)
  • 2020-11-29 06:22

    Remove the href attribute from your anchor tag

    0 讨论(0)
  • 2020-11-29 06:26

    Some browsers support the tabindex="-1" attribute, but not all of them, since this is not a standard behaviour.

    0 讨论(0)
  • 2020-11-29 06:27

    You could apply a JQuery handler to the element you want to target multiple elements with no tab stop.

    $(document).ready(function () {
        $('.class').attr('tabindex', '-1');
    });
    

    Would be one way to do it....

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