Skip to content

Instantly share code, notes, and snippets.

@henriquegogo
Created December 19, 2012 19:49
Show Gist options
  • Save henriquegogo/4339881 to your computer and use it in GitHub Desktop.
Save henriquegogo/4339881 to your computer and use it in GitHub Desktop.
Extreme simple modal using jQuery
$(document).on("click", ".modal", function() {
$(".modal-view").remove();
var imageSrc = $(this).attr("href");
var image = $("<img>").attr("src", imageSrc).attr("style", "box-shadow: 0 0 40px #000");
var modal = $("<div class='modal-view'>").attr("style","position: fixed; padding-top: 50px; top: 0; bottom: 0; left: 0; right: 0; z-index: 10; text-align: center; background: rgba(0, 0, 0, 0.5);");
modal.html(image)
.appendTo("body");
return false;
}).on("click", ".modal-view", function() {
$(this).remove();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment