本文介绍了如何通过 <ul> 使用键盘导航<li>元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!
问题描述
可能重复:
使用 jquery 的菜单的键盘导航
我使用 <ul> 创建了一个菜单.<li>
标记并在用户按下文本框中的 Enter
键时将其显示给用户.他可以使用鼠标选择菜单项目(在菜单中导航),但我也希望允许他使用键盘的向上/向下按钮从该菜单中选择项目.
I created a menu using <ul> <li>
tags and showing it to the user when he presses Enter
key in the textbox. He can select items of the menu (navigate in menu) using mouse but I want also to allow him to select items from that menu using up/dow buttons of the keyboard for example.
有没有办法使用 jQuery 或 CSS 来做到这一点?
Is it any way to do that using jQuery or CSS?
我的菜单结构如下:
注意:<li>
元素也有背景图片.
Note: <li>
element has a background image also.
推荐答案
工作中的jsFiddle
以下是如何处理循环选择:
Here is how to handle circular selection:
css:
这篇关于如何通过 <ul> 使用键盘导航<li>元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!