通過鍵盤上下鍵 JS事件,控制候選詞的選擇項

效果圖

JS代碼

    //上下鍵 選擇事件  searchBackgroud?為樣式,只做標記,無實質樣式,因為和其他樣式不兼容,只能添加CSS$(document).keydown(function (event) {var upDownClickNum = $("#SearchTips .searchBackgroud ").length;if ($("#SearchTips").css("display") == "block") {alert(event.keyCode)//38:上  40:下if (event.keyCode == 38) {if (upDownClickNum < 1) {$("#SearchTips li:last a").css({ "background": "#f0f0f0" }).addClass("searchBackgroud");} else {$("#SearchTips .searchBackgroud ").removeClass("searchBackgroud").css({ "background": "" }).parent().prev().children().addClass("searchBackgroud").css({ "background": "#f0f0f0" });}stopDefault(event);//不阻止光標戶向前移動} else if (event.keyCode == 40) {if (upDownClickNum < 1) {$("#SearchTips li:first a").css({ "background": "#f0f0f0" }).addClass("searchBackgroud");} else {$("#SearchTips .searchBackgroud").removeClass("searchBackgroud").css({ "background": "" }).parent().next().children().addClass("searchBackgroud").css({ "background": "#f0f0f0" });}stopDefault(event);}upDownClickNum++;}});//阻止事件執行function stopDefault(e) {//阻止默認瀏覽器動作(W3C)   if (e && e.preventDefault) {//火狐的 事件是傳進來的e  
            e.preventDefault();}//IE中阻止函數器默認動作的方式   else {//ie 用的是默認的event  event.returnValue = false;}}

?

html代碼

<html><head></head><body><ol id="SearchTips" class="search_list" style="display: none;"> <li> <a href="/VIEW/HouseSecond/HouseSecondList.html?r=1&amp;c=138&amp;rs=鳳凰北新村1區" onclick="ga('send', 'pageview', '1');">鼓樓 鳳凰北新村<span><b>1</b> </span>區 西江濱 待售(1) </a> </li> <li> <a href="/VIEW/HouseSecond/HouseSecondList.html?r=1&amp;c=122&amp;rs=鳳凰北新村1區" onclick="ga('send', 'pageview', '1');">鼓樓 鳳凰北新村<span><b>1</b> </span>區 萬寶商圈 待售(1) </a> </li> <li> <a href="/VIEW/HouseSecond/HouseSecondList.html?r=5&amp;c=129&amp;rs=怡美嘉園1期" onclick="ga('send', 'pageview', '1');">倉山 怡美嘉園<span><b>1</b> </span>期[怡美嘉園] 倉山步行街 待售(3)</a></li> <li> <a href="/VIEW/HouseSecond/HouseSecondList.html?r=5&amp;c=146&amp;rs=怡美嘉園1期" onclick="ga('send', 'pageview', '1');">倉山 怡美嘉園<span><b>1</b> </span>期[怡美嘉園] 三叉街 待售(3) </a></li> <li> <a href="/VIEW/HouseSecond/HouseSecondList.html?r=3&amp;c=127&amp;rs=福興花園1期" onclick="ga('send', 'pageview', '1');">晉安 福興花園<span><b>1</b> </span>期 鼓山新東區 待售(7)</a> </li> <li> <a href="/VIEW/HouseSecond/HouseSecondList.html?r=3&amp;c=141&amp;rs=福興花園1期" onclick="ga('send', 'pageview', '1');">晉安 福興花園<span><b>1</b> </span>期 福馬路 待售(7)</a></li><li> <a href="/VIEW/HouseSecond/HouseSecondList.html?r=7&amp;rs=融匯山水1期" onclick="ga('send', 'pageview', '1');">閩侯 融匯山水<span><b>1</b> </span>期 待售(32)</a></li> <li> <a href="/VIEW/HouseSecond/HouseSecondList.html?r=5&amp;rs=振興花園1期">倉山 振興花園<span><b>1</b> </span></a></li><li> <a href="/VIEW/HouseSecond/HouseSecondList.html?r=3&amp;c=155&amp;rs=彩虹鋪景" onclick="ga('send', 'pageview', '1');">晉安 彩虹鋪景[隆盛小區 <span><b>1</b> </span>#樓] 五四路(溫泉公園) 待售(6)</a></li><li> <a href="/VIEW/HouseSecond/HouseSecondList.html?r=3&amp;c=142&amp;rs=彩虹鋪景" onclick="ga('send', 'pageview', '1');">晉安 彩虹鋪景[隆盛小區 <span><b>1</b> </span>#樓] 火車站 待售(6) </a></li></ol></body>
</html>

?

轉載于:https://www.cnblogs.com/xiaoshi657/p/5445257.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/257273.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/257273.shtml
英文地址,請注明出處:http://en.pswp.cn/news/257273.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

物理競賽得獎學計算機,物理競賽林紫琪帶你探索清華學堂計算機科學實驗班”(姚班)...

林紫琪&#xff0c;34屆全國中學生物理競賽全國第22名&#xff0c;獲得女生最高分&#xff0c;入選國家集訓隊&#xff0c;現就讀于清華姚班。這是一條小科普&#xff1a;“清華學堂計算機科學實驗班”(姚班)由世界著名計算機科學家姚期智院士于2005年創辦&#xff0c;致力于培…

Jmeter===Jmeter中使用CSV Data Set Config參數化不重復數據執行N遍(轉)

Jmeter中使用CSV Data Set Config參數化不重復數據執行N遍 要求&#xff1a; 今天要測試上千條數據&#xff0c;且每條數據要求執行多次&#xff0c;&#xff08;模擬多用戶多次抽獎&#xff09; 1.用戶id有175個&#xff0c;且沒有任何排序規則&#xff1b; 2.要求175個用戶都…

[轉]wireshark 實用過濾表達式(針對ip、協議、端口、長度和內容) 實例介紹

首先說幾個最常用的關鍵字&#xff0c;“eq” 和 “”等同&#xff0c;可以使用 “and” 表示并且&#xff0c;“or”表示或者。“!" 和 "not” 都表示取反。 一、針對wireshark最常用的自然是針對IP地址的過濾。其中有幾種情況&#xff1a; &#xff08;1&#xff0…

[Flexbox] Using order to rearrange flexbox children

Using the order property we alter the order in which flexbox children appear on the page, without making changes to the dom. Desktop Mobile 轉載于:https://www.cnblogs.com/Answer1215/p/5453671.html

計算機怎么更改用戶頭像像,Win10系統電腦賬戶頭像怎么改成系統默認狀態?

為了保護電腦的安全&#xff0c;我們可以設置登錄賬號密碼&#xff0c;而賬號的頭像也是可以自行更換的。但是&#xff0c;某些時候&#xff0c;因為一些原因&#xff0c;我們需要將Win10系統賬戶的頭像去掉&#xff0c;即改成默認狀態。但是很多人都不清楚該怎么操作&#xff…

SPFA模板

今天去聽2015ZJOI浙江省隊第二試的集訓&#xff0c;早上就是聽得云里霧里的ORZ&#xff0c;下午某兩集訓隊大神過來將題目&#xff0c;第一個進了IOI的我只聽懂了10%ORZ&#xff0c;第二個人機交互很好玩&#xff0c;找個時間單獨寫下。 順便附帶膜拜各位聚聚&#xff0c;保我明…

LCM在Kernel中的代碼分析

lcm的分析首先是mtkfb.c 1.mtk_init中platform_driver_register(&mtkfb_driver)注冊平臺驅動 panelmaster_init(); DBG_init(); mtkfb_ipo_init(); 2.mtkfb_probe進行普配 3.然后執行primary_display_init(mtkfb_find_lcm_driver(),lcd_fps); 4.mtkfb_find_lcm_driver()進行…

html ascii編碼方式,HTML 字符集 參考手冊

要正確顯示一個 HTML 頁面&#xff0c;瀏覽器必須知道要使用的字符集(字符編碼)。HTML 字符集在 HTML 中&#xff0c;正確的字符編碼是什么&#xff1f;HTML5 中默認的字符編碼是 UTF-8。這并非總是如此。早期網絡的字符編碼是 ASCII 碼。后來&#xff0c;從 HTML 2.0 到 HTML …

JavaScript 中的閉包和作用域鏈(讀書筆記)

要想理解閉包&#xff0c;應當先理解JavaScript的作用域和作用域鏈。 JavaScript有一個特性被稱之為“聲明提前&#xff08;hoisting&#xff09;”&#xff0c;即JavaScript函數里聲明的所有變量&#xff08;但不涉及賦值&#xff09;都被“提前”至函數體的頂部&#xff0c;“…

leetcode jump game ii

題目&#xff1a; Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Your goal is to reach the last index in the minimum numb…

韓師師范學院計算機科學與技術在哪個學區,2017年韓山師范學院本科插班生考試《數據結構》A卷...

韓山師范學院2017年本科插班生考試試卷計算機科學與技術 專業 數據結構 試卷(A 卷)一、單項選擇題(每題2分&#xff0c;共30分)1. 對線性表&#xff0c;在下列哪種情況下應當采用鏈表表示&#xff1f;( ) A. 經常需要隨機地存取元素 B. 經常需要進行插入和刪除操作 C. 表中元素…

JAVA取隨機數,石頭剪刀布實例

一、取隨機數&#xff1a; import java.util.Random; //導入隨機數 public class Test{public static void main(String[] args){Random xx new Random(); //聲明隨機數int number xx.nextInt(10); //賦值隨機數給numberSystem.out.println("隨機數…

計算機網絡犯罪和一般犯罪的不同,論計算機網絡犯罪題稿.doc

目 錄摘要2第一章、網絡犯罪概念、特點以及構成特征5(一)網絡犯罪的概念認定5(二)網絡犯罪的特點6(三)網絡犯罪的構成7第二章、?網絡犯罪的類型9(一)網絡色情和性騷擾9(二)欺詐9(三)販賣、銷售違禁物品11(四)妨害名譽、侵犯個人隱私12(五)?制造、傳播計算機病毒12第三章、?網…

實例變量和靜態變量(或類變量static)

一個類通過使用運算符new可以創建多個不同的對象&#xff0c;這些對象將被分配不同的內存空間&#xff0c;準確的說法是&#xff1a;不同對象的實例變量將被分配不同的內存空間&#xff0c;如果類中有類變量&#xff0c;那么所有對象的這個類變量都被分配到同一處內存&#xff…

DB2 數據庫清表語句

truncate table DWDM2.tablename IMMEDIATE; alter table DWDM1.tablename activate not logged initially with empty table&#xff1b; but which one is best ? the truncate should be better 轉載于:https://www.cnblogs.com/TendToBigData/p/10501485.html

cnblogs_504 Gateway Time-out

地址&#xff1a;http://zzk.cnblogs.com/s?tb&w%E6%B1%82%E8%81%8C 504 Gateway Time-out 504 Gateway Time-out The gateway did not receive a timely response from the upstream server or application. Sorry for the inconvenience. Please report this message an…

第一階段

初步實現了相機的調用&#xff0c;做了簡單界面&#xff0c;并沒有實現核心功能 Button button (Button) findViewById(R.id.sao);button.setOnClickListener(new OnClickListener(){Overridepublic void onClick(View v) {Intent intent new Intent(MediaStore.ACTION_IMAGE…

JavaScript 詳說事件機制之冒泡、捕獲、傳播、委托

DOM事件流&#xff08;event flow &#xff09;存在三個階段&#xff1a;事件捕獲階段、處于目標階段、事件冒泡階段。 事件捕獲&#xff08;event capturing&#xff09;&#xff1a;通俗的理解就是&#xff0c;當鼠標點擊或者觸發dom事件時&#xff0c;瀏覽器會從根節點開始…

很棒的HTML5效果實例

2019獨角獸企業重金招聘Python工程師標準>>> http://mrdoob.com/141/Internet_Explorer_with_WebGL 轉載于:https://my.oschina.net/u/3647620/blog/1552495

計算機一級網絡操作題沒點回答,計算機等級一級考試操作題1(附答案)

一、選擇題1、在計算機領域中通常用mips來描述______。a、計算機的運算速度 b、計算機的可靠性 c、計算機的可運行性 d、計算機的可擴充性2、微型計算機存儲系統中&#xff0c;prom是______。a、可讀寫存儲器 b、動態隨機存取存儲器 c、只讀存儲器 d、可編程只讀存儲器3、按161…