【发布时间】:2013-05-29 20:48:29
【问题描述】:
您好,我正在做一个画廊,您有拇指,每个人都选择主图像,如果您单击主图像,您应该得到一个叠加层,该叠加层内是图片和一些额外的 html。
好的,我几乎完成了 90% 的代码 http://jsfiddle.net/s6TGs/5/
我只使用 jquerytools .. 问题是当您选择第二个拇指时...您得到的叠加层是 thumb1 的叠加层..即使我确实更改了相应的 (rel="#target") 。所以我想我正在做或错过别的东西..
请有人向我解释为什么即使在相应的 rel 发生变化之后,触发器总是针对 item1。
提前致谢。
这是脚本
$(function() {
$(".scrollable").scrollable();
$(".items img").click(function() {
// see if same thumb is being clicked
if ($(this).hasClass("active")) { return; }
// calclulate large image's URL based on the thumbnail URL (flickr specific)
var url = $(this).attr("src").replace("_t", "");
var relo = $(this).attr("relo");
// get handle to element that wraps the image and make it semi-transparent
var wrap = $("#image_wrap").fadeTo("medium", 0.5);
// the large image from www.flickr.com
var img = new Image();
// call this function after it's loaded
img.onload = function() {
// make wrapper fully visible
wrap.fadeTo("fast", 1);
// change the image
wrap.find("img").attr("src", url);
wrap.find("img").attr("rel", relo);
};
// begin loading the image from www.flickr.com
img.src = url;
// activate item
$(".items img").removeClass("active");
$(this).addClass("active");
// when page loads simulate a "click" on the first image
}).filter(":first").click();
});
// This makes the image Overlay with a div and html
$(document).ready(function() {
$("img[rel]").overlay();
});
【问题讨论】:
标签: javascript jquery css jquery-tools