返回列表 發帖
你可以先定義一個變數 currentFocus 來存放目前 focus 在第幾個 button 上,另外定義一組 array 存放你想要循環的 button id。需要處理的動作會有以下幾個:

1. 當某個 button onblur 時,將 currentFocus 設為 0 (有可能是其他非 button 的元素取得 focus)
2. 當某個 button focus 時,將 currentFocus 設定為該 button 在 array 中的序號
3. 當按下「上」或「下」時,透過 currentFocus 判斷下一個或上一個該 focus 的元素,並執行

大致是這樣
To infinity and beyond!

TOP

返回列表 回復 發帖