Javascript to detect whether the dropdown of a select element is visible

后端 未结 7 1026
甜味超标
甜味超标 2020-12-19 08:39

I have a select element in a form, and I want to display something only if the dropdown is not visible. Things I have tried:

  • Watching for click events, where
7条回答
  •  再見小時候
    2020-12-19 09:06

    Keep track of the state using a JavaScript varialbe. We'll call it "openX".

    onfocus="openX=true" onblur="openX=false" onchange="openX=false"

提交回复
热议问题