Prevent tabstop on A element (anchor link) in HTML

别等时光非礼了梦想. 提交于 2019-11-26 11:03:45

问题


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


回答1:


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




回答2:


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.




回答3:


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




回答4:


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.




回答5:


Remove the href attribute from your anchor tag



来源:https://stackoverflow.com/questions/1561021/prevent-tabstop-on-a-element-anchor-link-in-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!