javascript - jQuery hide when clicked on anything but div -
this question has answer here:
i've tried answers similair questions of without success.
in jsfiddle: http://jsfiddle.net/h2hzn/6/
i have set when press escape goes away using this:
$(document).keyup(function(e) { if (e.keycode == 27) { $("#signup").fadeout(250); $("#window").slideup(450); } });
but want go away when click anywhere black box. in advance.
this should demo
$(window).click(function() { if(this.id !== "window") { $("#signup").fadeout(250); $("#window").slideup(450); } }); $("#window").on("click", function(e){ e.stoppropagation(); });
for latest fiddle you've provided,
latest solution me,
$("#popup").add("#signup_signin a").click(function(e) { $("#signup").fadein(400); $("#window").slidedown(450); e.stoppropagation(); }); $(document).keyup(function(e) { if (e.keycode == 27) { $("#signup").fadeout(250); $("#window").slideup(450); } }); $(window).click(function() { if(this.id !== "popup") { $("#signup").fadeout(250); $("#window").slideup(450); } }); $("#window").on("click", function(e){ e.stoppropagation(); });
it fades out when esc used or clicked anywhere black box , sign button.
Comments
Post a Comment