Is there a way to prevent the default behavior of the a tag with the tabindex = '-1' attribute?

北慕城南 提交于 2020-03-25 18:48:22

问题


when the descendant node of the region with tabindex -1(this is a modal dialog window) has a tag, in the macOS safari browser I needed the tabindex = '-1' attribute to trigger the click event on the a tag. However, this causes an issue where the modal scroll goes up when clicking the a tag. The same issue occurred when adding the href = "javascript: void (0)" attribute to the a tag and calling e.preventDefault() inside a function that works when a tag click event is called.

<div tabindex="-1" role="dialog" aria-hidden="true">
  <div class="scrollbox">
    <a tabindex="-1" href="javascript:void(0);">click</a>
  </div>
</div>

What is causing this problem? Is there a workaround in the current situation?

While looking for a solution, I also found the following issues, but did not find the answer I wanted. What's the tabindex="-1" in bootstrap for

来源:https://stackoverflow.com/questions/60631666/is-there-a-way-to-prevent-the-default-behavior-of-the-a-tag-with-the-tabindex

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