auto-complete search suggestion drop-down popup

前端 未结 3 1331
南旧
南旧 2021-01-24 08:08

Im trying to make a popup div (when a text-box value changes) and it can be closed (visibility: none) by clicking anywhere outside the div. Similar to Google suggestion drop-dow

3条回答
  •  Happy的楠姐
    2021-01-24 08:30

    One method would be to popup a div behind that covers the whole screen (invisible), and capture clicks on that div to close both popup divs. You could also try capturing clicks on the body tag and that should catch clicks anywhere outside the div (or inside the div as well if events bubble - you may want to perform some testing).

    Sometimes an easier method is to use a timeout, like popup CSS menus that disappear once your mouse has been off of the menu for a couple of seconds. You can catch the onmouseleave event, start a timer, and as long as there isn't another onmouseenter in say, two seconds, then hide the popup div.

    Hope this helps!

提交回复
热议问题