简体   繁体   English

从超链接中删除tabindex属性

[英]Remove tabindex attribute from hyperlink

I have an oracle apex page. 我有一个Oracle顶点页面。 I defined a tabscontainer region in it. 我在其中定义了一个tabscontainer区域。 There are two sub regions to this region. 该区域有两个子区域。 There is a hyper link inside each sub region, which is coded like 每个子区域内都有一个超级链接,其编码方式如下

<a class="t-Tabs-link" href="#SR_R1" role="presentation" tabindex="-1">
  <span>1</span>
</a>

in first region and 在第一区域和

<a class="t-Tabs-link" href="#SR_R2" role="presentation" >
  <span>2</span>
</a>

in second region. 在第二区域。

I want to remove tabindex property of first region from this code using javascript and add property tabindex="-1" to second region.I can not add an id to this hyper link since oracle apex do not allow to edit default html attributes. 我想使用javascript从此代码中删除第一区域的tabindex属性,并将属性tabindex =“-1”添加到第二区域。我无法向此超级链接添加ID,因为oracle apex不允许编辑默认的html属性。 How can I do this without assigning id ? 如何在不分配ID的情况下执行此操作? or is there any way that I can assign id to this hyper link? 或有什么方法可以为该超级链接分配ID?

Use Jquery removeAttr to remove the attribute from any element. 使用Jquery removeAttr从任何元素中删除属性。

Select the first index element and simply remove attribute from it 选择第一个索引元素,然后从中删除属性

$(".t-Tabs-link").eq(0).removeAttr("tabindex");

You can also set attribute via Jquery attr() function 您还可以通过JQuery attr()函数设置属性

$(".t-Tabs-link").eq(1).attr("tabindex" , -1);

example

You can use document.querySelector and you don't need to know <a> 's ID. 您可以使用document.querySelector ,而无需知道<a>的ID。

You can remove tabindex by this. 您可以以此删除tabindex

document.querySelector('.t-Tabs-link:first-child').removeAttribute('tabindex');

You can set tabindex by this. 您可以以此设置tabindex

document.querySelector('.t-Tabs-link:last-child').setAttribute('tabindex', -1);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM