hide - jQuery toogle by ESC and clicking -


i have simple script

$(".showhide").click(function (e) {     e.stoppropagation();     jquery(this).children('.showhide').toggle(); }); 

i dont know how 1) hide .modal if esc presed 2) hide .modal if user click outside of .modal-inside

https://jsfiddle.net/zkx9gt2u/1/

this should trick.

$(".showhide").click(function (e) {     e.stoppropagation();     $(".showhide").children('.showhide').toggle(); });  $(".modal-inside").click(function (e) {     e.stoppropagation(); });  $(document).bind('keydown', function(e) {          if (e.which == 27) {             $(".showhide").children('.showhide').hide();         }     }); 

edit

i came across bootstrap modal got added in v3. want. starting point official site , here.

e.g. if wish close modal using esc key, have this:

var options = {     "backdrop" : "static" }  $('#id-of-modal').modal(options); 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -