2009-08-14 2 views
0

jQueryを使用してキャプション付きの画像スライドショーを設定しました。画像とキャプションのdiv全体がリンクされたアンカーで囲まれています。何らかの理由で、スライドショー機能がうまく動作しても、アンカーは最後のセットと同じままです。すなわち、以下の例を使用すると、スライドショーコンテンツは「ショー/」にのみリンクされます。画像回転はjQueryを使用していますがアンカーは同じです

<div id="mainfeature"> 
     <a href="http://www.google.com" class="show feature"> 
     <img src="http://union.ic.ac.uk/arts/mtsoc/wp-content/uploads/2009/07/sweetcharity_front.png" /> 
     <div class="caption"> 
      <span class="tag">2009 Tour Show</span> 
      <span class="title">Sweet Charity</span> 
      <span class="detail">29th July until 8th August</span> 
     </div></a> 
     <a href="shows/" class="feature"> 
     <img src="http://union.ic.ac.uk/arts/mtsoc/wp-content/gallery/2009-forum/Picture%20044.jpg" width="650px" /> 
     <div class="caption"> 
      <span class="tag">2009 Spring Show</span> 
      <span class="title">A Funny Thing Happened on the Way to the Forum</span> 
      <span class="detail"></span> 
     </div></a> 
</div> 

あなたはここでそれを外出して掘る必要はありませんちょうどそうhttp://union.ic.ac.uk/arts/mtsoc/

の実施例を参照してください。スライドショーのjavascriptのです:

function slideShow() { 

    //Set the opacity of all images to 0 
    $('#mainfeature a').css({opacity: 0.0}); 

    //Get the first image and display it (set it to full opacity) 
    $('#mainfeature a:first').css({opacity: 1.0}); 

    //Set the caption background to semi-transparent 
    $('#mainfeature .caption').css({opacity: 0.7}); 

    //Call the gallery function to run the slideshow 
    setInterval('main_gallery()',8000); 
} 

function main_gallery() { 

    //if no IMGs have the show class, grab the first image 
    var current = ($('#mainfeature a.show')? $('#mainfeature a.show') : $('#mainfeature a:first')); 

    //Get next image, if it reached the end of the slideshow, rotate it back to the first image 
    var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#mainfeature a:first') :current.next()) : $('#mainfeature a:first'));  

    //Set the fade in effect for the next image, show class has higher z-index 
    next.css({opacity: 0.0}) 
    .addClass('show') 
    .animate({opacity: 1.0}, 1000); 

    //Hide the current image 
    current.animate({opacity: 0.0}, 1000) 
    .removeClass('show'); 

    //Set the opacity to 0 
    $('#mainfeature .caption').animate({opacity: 0.0}, 500);  

    //Animate the caption, opacity to 0.7 
    $('#mainfeature .caption').animate({opacity: 0.7}, 1000); 
} 

任意のアイデア?

答えて

0

回転したときに変更する必要があるアンカーのZ-インデックスがわかります。私はショークラスを使用してこれを行いましたので、jsは変更する必要はありませんでした。

関連する問題