Home  >  Q&A  >  body text

javascript - Zhihu search box still has focus even when there is a drop-down menu. Why?

When using the up and down keys to scroll the drop-down menu, the input focus is still retained in the search box. How to do this?

漂亮男人漂亮男人2710 days ago1026

reply all(1)I'll reply

  • ringa_lee

    ringa_lee2017-05-19 10:12:28

    Because the focus should always be on the search box, listening for input keyboard events,
    when the direction key is pressed, it is handed over to the drop-down menu management. The drop-down menu calculates the index according to the direction, and adds the activation style to the corresponding entry

    reply
    0
  • Cancelreply