谁能告诉我这段代码有什么问题?我有一个图片库,我想为画廊的每张图片添加一个弹出窗口,但它只在同一张图片上打开。我尝试了许多不同的示例,它们大部分时间仅适用于一个链接,而不适用于所有画廊链接。
点击购物车图标
$(document).ready(function(){
//Image pop on mouseover
$("#gallery2 a").append('<span id=myspan class=myspanclass><a id=deleteimg href="#" class="delete" ></a><a href="#" class="showreranks" id="d" ><img src="images/insert_to_shopping_cart.png" class="imgOpa" size=20 width=20 border=0></a></span>');
$(this).find('#gallery2 a.showreranks').append('<div id="popupdiv" class="closemediv"><div class="closemediv"><a href=""><img src="http://icons.iconarchive.com/icons/kyo-tux/aeon/16/Sign-Close-icon.png" width="16"></a></div><div id="list_preview" class="popupcontent"><p>Some Text!</div></div>');
//makes sure when deleting image it does not pops the fancybox
$('span a').bind('click', function(e) {
e.stopPropagation();
});
$(".photo-link").on({
mouseenter: function () {
$(this).find('span').stop().delay(100).fadeIn(200);
},
mouseleave: function () {
$(this).find('span').stop(true).fadeOut(0);
}
});
//Popup Div Start
$(function () {
$('a.showreranks').click(function () {
position = $(this).position();
$('body').append('<div class="overlay"></div>')
$('#popupdiv').fadeIn(300);
$('#popupdiv').css('top', position.top + 17);
return false;
});
});
(function (a) {
jQuery.fn.screencenter = function () {
this.css("position","absolute");
this.css("top", (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() + "px");
this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + "px");
return this;
}
})(jQuery);
//Popup Div End
});
</SCRIPT>