2012-01-05 22 views
0

以下のコードでこれらの変更をどうすればできますか?画像ギャラリー機能を変更する

  • <div id="main">をクリックすると、サム画像が表示されます。
  • 「blank.gif」の<div id="main">
  • セットURLのサムネイル画像の下に表示するサムネイル画像のタイトルは(私が意味する、我々はまた、親指の画像、その親指画像の<div id="main"> GETのURLをクリックします。私は完全に利用するために、この変更を行いたいですここで任意の画像の-screen)

コード:私は私の答えを得る

<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(); 

答えて

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); 

幸運。

関連する問題