會(huì)出現(xiàn)在沒(méi)有點(diǎn)擊開(kāi)ul時(shí)也可以切換
? ? ?if(e.keyCode==40&&? ? menu.style.display=='block'
){
? ? ? ? ? ? ?index++;
? ? ? ? ? ? ?if(index>=as.length){
? ? ? ? ? ? ? ?index=0;
? ? ? ? ? ? ?}
? ? ? ? ? ? ?as[index].style.background="#ccc";
? ? ? ? ? }
? ? ? ? ? // 如果按下了向上方向鍵
? ? ? ? ? if(e.keyCode==38&&? ? menu.style.display=='block'
){
? ? ? ? ? ? ?if(index<=0){
? ? ? ? ? ? ? ?index=as.length;
? ? ? ? ? ? ?}
? ? ? ? ? ? ? ?index--;? ?
? ? ? ? ? ? ?as[index].style.background="#ccc";? ? ??
? ? ? ? ? }
在if中加入判斷必須在ul為block才能用鍵盤(pán)操作
2022-11-09
那是事件一起發(fā)現(xiàn)了,要做處理的