Prevent tabstop on A element (anchor link) in HTML

2019-01-07 14:11发布

Is it possible to cancel an <a href="..."> from being tabstopped in any browser? I would like to do this without Javascript.

5条回答
我只想做你的唯一
2楼-- · 2019-01-07 14:39

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

查看更多
Evening l夕情丶
3楼-- · 2019-01-07 14:42

Remove the href attribute from your anchor tag

查看更多
We Are One
4楼-- · 2019-01-07 14:50

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.

查看更多
相关推荐>>
5楼-- · 2019-01-07 14:51

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.

查看更多
6楼-- · 2019-01-07 14:58

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....

查看更多
登录 后发表回答