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
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
Post a Comment