如何在没有href =“#"的情况下将焦点放在锚标记上 [英] How to give focus to anchor tag without href="#"

查看:47
本文介绍了如何在没有href =“#"的情况下将焦点放在锚标记上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用键盘标签时如何聚焦?

How to give focus when using keyboard tab?

<a class="ui-datepicker-prev ui-corner-all" data-handler="prev" data-event="click" title="Prev"><span class="ui-icon ui-icon-circle-triangle-w">Prev</span></a>

我尝试使用这样的CSS

I tried using css like this

ui-datepicker-prev:focus { border:1px solid red}

但这不能很好地工作.有人知道吗?

But this doesn't work well. Anyone know ?

推荐答案

首先,类选择器应以点开头:

First, class selector should start with a dot:

.ui-datepicker-prev:focus {border: 1px solid red; }

对于默认情况下无法使用焦点的元素可以使用键盘导航,设置 tabindex ="0" 属性应该会有所帮助.

As for being able to use keyboard navigation for elements that are nonfocusable by default, setting tabindex="0" attribute should help.

这篇关于如何在没有href =“#"的情况下将焦点放在锚标记上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆