This is what I’ve done:
$('#keks-overlay').hide();
$('#click').click(function(){
$('#keks-overlay').toggle(450);
});
$('#close-overlay').click(function(){
$('#keks-overlay').toggle(250);
});
jsFiddle: http://jsfiddle.net/rHKkD/22/
This works fine, but it shows/hides (toggles) only by clicking the “X” (#close-overlay).
I’d like do something like the fancybox-effect: fade out on clicking anywhere on the whole body.
Thanks for your help.
You can add an event handler to a
divthat contains the whole page (or the document itself), andhide()the overlay in that handler.However, if you want to prevent clicks on the overlay itself from triggering the
hide(), you could either add an event handler to the overlay that returns false (to prevent the event from bubbling up), or place the overlay outside thedivthat holds the rest of your content (which works because the overlay hasabsolutepositioning).I updated your fiddle to show the second method.