因此,我今天在网站上进行了一些更新,并删除了我对重叠式广告的标题。我觉得我不需要。我暂时将上述代码注释掉,以测试我是否喜欢它。我确实喜欢没有文字的图像叠加层,但是现在我无法通过再次单击它来退出叠加层。为什么是这样?这是我的repo代码源。下面也是我的js代码。
/*************************************************************
Gallery Lightbox On Stories Page
**************************************************************/
//Problem: User when clicking on image goes to a dead end
//Solution: Create an overlay with the large image - Lightbox
var $overlay = $('<div id="overlay"></div>');
var $image = $("<img>");
// var $caption = $("<p></p>");
// An image to overlay
$overlay.append($image);
// A caption to overlay
// $overlay.append($caption);
// Add overlay
$("body").append($overlay);
// Capture the click event on a link to an image
$(".gallery a").click(function(event){
event.preventDefault();
var imageLocation = $(this).attr("href");
// Update overlay with the image linked in the link
$image.attr("src",imageLocation);
// Show the overlay.
$overlay.show();
// Get child's alt attribute and set caption
// var captionText = $(this).children("img").attr("alt");
// $caption.text(captionText);
// });
// When overlay is clicked
$overlay.click(function(){
// Hide the overlay
$overlay.hide();
});
/*************************************************************
Hide Email Using Javascript To Avoid Spam
**************************************************************/
//var parts = ["lpstories","yahoo","com",".","@"];
//var email = parts[0] + parts[4] + parts[1] + parts[3] + parts[2];
//document.getElementById("email").innerHTML=email;