會出現在沒有點擊開ul時也可以切換
? ? ?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才能用鍵盤操作
2022-11-09
那是事件一起發現了,要做處理的