简体   繁体   English

如何在 Javascript 滑块上设置 tabindex

[英]How to Set the tabindex on a Javascript Slider

I'm trying to set the tabindex on the arrows associated with a slider like this one , but the arrows get skipped when using tab to move from one element on the web page to the next.我正在尝试在与 这样的滑块关联的箭头上设置 tabindex,但是当使用 tab 从网页上的一个元素移动到下一个元素时,箭头会被跳过。 I tried this ...我试过这个...

    <a class="prev" onclick="plusSlides(-1).tabIndex = '3'">❮</a>
    <a class="next" onclick="plusSlides(1).tabIndex = '4'">❯</a>

... without success. ... 没有成功。 Maybe the tabIndex property requires that all elements are labeled w/ tabIndex for it to function?也许 tabIndex 属性要求所有元素都标记为带有 tabIndex 才能运行? IDK.身份证。

Any thoughts / comments on how to implement this are welcome.欢迎任何关于如何实现这一点的想法/评论。

<a class="prev" onclick="plusSlides(-1,3)">❮</a>
<a class="next" onclick="plusSlides(1,4)">❯</a>

function plusSlides(n,index) {
  showSlides(index += n);
}

function currentSlide(n,index) {
  showSlides(index = n);
}

send index in side function在辅助函数中发送索引

I found an answer here .我在这里找到了答案。 The slider's arrows are traversable w/ the keyboard's tab key when the tabindex is set as follows:当 tabindex 设置如下时,滑块的箭头可以通过键盘的 tab 键遍历:

    <a class="prev" id="previd" tabindex="0" onclick="plusSlides(-1)">❮</a>
    <a class="next" id="nextid" tabindex="0" onclick="plusSlides(1)">❯</a>

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

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