admin管理员组文章数量:1417404
I have a button and I want it to change to green when I access it by tab key. I have written the code for hover by mouse but I want that when a user a goes to the button using tab key then it should change the color.
I have a button and I want it to change to green when I access it by tab key. I have written the code for hover by mouse but I want that when a user a goes to the button using tab key then it should change the color.
Share Improve this question asked Aug 12, 2014 at 14:00 abhiabhi 311 silver badge6 bronze badges 3- please post you have so far – X-Pippes Commented Aug 12, 2014 at 14:00
- What have you tried so far? and can you post some code for us to have a look at – Izzy Commented Aug 12, 2014 at 14:01
- I think you need something like focus event – Aliaksei Bulhak Commented Aug 12, 2014 at 14:01
1 Answer
Reset to default 6Simply use the :focus
pseudo selector
Demo Fiddle
button:focus{
color:green;
}
More on :focus
from MDN
The :focus CSS pseudo-class is applied when a element has received focus, either from the user selecting it with the use of a keyboard or by activating with the mouse (e.g. a form input).
You may also wish to give the button
a tabindex
attribute to control its tab order.
本文标签: javascriptbutton color change by tab key pressStack Overflow
版权声明:本文标题:javascript - button color change by tab key press - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745260852a2650351.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论