久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何通過 <ul> 使用鍵盤導(dǎo)航<li&

How to navigate with keyboard through lt;ulgt; lt;ligt; element(如何通過 lt;ulgt; 使用鍵盤導(dǎo)航lt;ligt;元素)
本文介紹了如何通過 <ul> 使用鍵盤導(dǎo)航<li>元素的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

可能重復(fù):
使用 jquery 的菜單的鍵盤導(dǎo)航

我使用 <ul> 創(chuàng)建了一個菜單.<li> 標(biāo)記并在用戶按下文本框中的 Enter 鍵時將其顯示給用戶.他可以使用鼠標(biāo)選擇菜單項目(在菜單中導(dǎo)航),但我也希望允許他使用鍵盤的向上/向下按鈕從該菜單中選擇項目.

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?

我的菜單結(jié)構(gòu)如下:

<div class="services">
  <div class="items">
    <ul>                           
        <li class="mail-icon"><a href="#" id="mail"><?php echo $langmsg['mail']; ?></a></li>
        <li class="forum-icon"><a href="#" id="forum"><?php echo $langmsg['forum']; ?></a></li>
        <li class="chat-icon"><a href="#" id="chat"><?php echo $langmsg['chat']; ?></a></li>
    </ul>
  </div>
</div>

注意:<li> 元素也有背景圖片.

Note: <li> element has a background image also.

推薦答案

工作中的jsFiddle

以下是如何處理循環(huán)選擇:

Here is how to handle circular selection:

if (e.keyCode == 38) { // up
    var selected = $(".selected");
    $(".services li").removeClass("selected");

    // if there is no element before the selected one, we select the last one
    if (selected.prev().length == 0) {
        selected.siblings().last().addClass("selected");
    } else { // otherwise we just select the next one
        selected.prev().addClass("selected");
    }
}

css:

.services li.selected {
    background-color: grey;   
}

這篇關(guān)于如何通過 &lt;ul&gt; 使用鍵盤導(dǎo)航&lt;li&gt;元素的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How to check for duplicate CSS rules?(如何檢查重復(fù)的 CSS 規(guī)則?)
Remove duplicate CSS declarations across multiple files(刪除多個文件中的重復(fù) CSS 聲明)
How can I duplicate a div onclick event?(如何復(fù)制 div onclick 事件?)
opening html from google drive(從谷歌驅(qū)動器打開 html)
How to embed videos from Google drive to webpage?(如何將視頻從 Google 驅(qū)動器嵌入到網(wǎng)頁?)
How to view Google drive pdf link in iframe(如何在 iframe 中查看 Google Drive pdf 鏈接)
主站蜘蛛池模板: 手机看黄av免费网址 | 色资源在线视频 | 日本三级电影在线看 | 日韩国产在线 | www国产成人免费观看视频,深夜成人网 | 久久久久久久久毛片 | 午夜激情免费 | 在线观看亚洲专区 | 国产四虎| 九九综合 | 91国自产| 久久r精品 | 午夜免费福利片 | 国产精品一区二区精品 | 国产精品区一区二 | 久久99网| 超碰人人爱| 精品啪啪 | 日本三级网址 | 男女羞羞视频网站 | 天天曰天天干 | 国产一区中文字幕 | 99精品视频免费观看 | 亚洲国产精品成人久久久 | av黄色免费在线观看 | 99久久精品免费 | 午夜一级黄色片 | 成年视频在线观看福利资源 | 中文字幕 欧美 日韩 | 亚洲精品一二三 | 国产视频1区2区 | 国产精品久久久久久久一区探花 | 日韩在线免费视频 | 亚洲精品一区中文字幕乱码 | 日韩在线综合 | 成人免费看黄网站在线观看 | 欧美亚洲第一区 | 久久精品国产亚洲 | 欧美亚洲另类丝袜综合网动图 | 麻豆视频国产在线观看 | 久久精品亚洲 |