The following code is fairly self explanatory, but I am running in to an issue binding the click event to an element that has been created.
You can see at line 25 I
// Overlay click = trigger out
$('#overlay').click(function () {
$('#overlay').fadeOut(1000);
$('.modal').fadeOut(200);
});
is triggered on page load, when the #overlay element doesn't exist. If you move this piece of code inside the $('a[name=modal]').click(function(e) { part, but after the $('body').append(''); part, it should work.