更改图库功能

时间:2012-01-05 10:02:21

标签: javascript jquery html css

我如何在下面的代码中进行这些更改?

  • 当我们点击,拇指图像时显示<div id="main">的缩略图图片标题。
  • <div id="main">
  • 下方显示缩略图图片标题
  • 为&#34; blank.gif&#34;设置网址缩略图。 (我的意思是当我们点击拇指图像时,<div id="main">获取该拇指图像的URL,我也希望对任何图像的全屏使用进行此更改)

代码在这里:

<div id="main">
    <p><img src="blank.gif" /></p>
</div>

$(".productthumbs img").click(function() {
    // calclulate large image's URL based on the thumbnail URL (flickr specific)
    var url = $(this).attr("src");
    // get handle to element that wraps the image and make it semitransparent
    var wrap = $("#main").fadeTo("medium", 0.5);
    // the large image from flickr
    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);
    };
    // begin loading the image from flickr
    img.src = url;
// when page loads simulate a "click" on the first image
}).filter(":first").click();

1 个答案:

答案 0 :(得分:0)

我得到了答案,把它放在这里,任何人都有同样的要求......

<div id="main">
    <p><img src="blank.gif" /></p>

    <div id="title">
       <a href="about:blank"><h5>...</h5> </a>
    </div>
</div>

并添加以下行:

wrap.find('h5').html(title);
wrap.find("a").eq(1).attr("href", url);

之后:

    wrap.find("img").attr("src", url);
祝你好运。

相关问题