Does anybody know how to make a Popover close by pressing the escape button? | XM Community
Skip to main content
Solved

Does anybody know how to make a Popover close by pressing the escape button?

  • August 7, 2018
  • 2 replies
  • 139 views

Curious if anybody knows how to make a Popover window close by pressing the escape button for Website / App feedback. Thanks!

Best answer by SaurabhPujare_Ugam

Hello @Nash9392 Try this if it help.. $('#example').popover(); $(document).keyup(function (event) { if (event.which === 27) { $('#example').popover('hide'); } });

2 replies

SaurabhPujare_Ugam
QPN Level 5 ●●●●●
Forum|alt.badge.img+18
  • QPN Level 5 ●●●●●
  • Answer
  • August 7, 2018
Hello @Nash9392 Try this if it help.. $('#example').popover(); $(document).keyup(function (event) { if (event.which === 27) { $('#example').popover('hide'); } });

  • August 7, 2018
Hello @Nash9392 , Add this java script code to the question implementing popover Event.observe(document,'keydown',function(e){ if (e.keyCode == 27) // if esc was pressed { //add display:none css to popover } Note: please give your popover code, so that I can give commented part of the above code i.e changing css using js