2011-06-29 69 views
0

我已經設法獲得了一個輪播,以便在圖像更改時它將顯示您正在查看的數字圖像。Jquery - 爲活動Carousel圖像的圖像標籤添加類

如果是選擇圖像編號3,則列表中的3個列是當前圖像的代碼。我能得到這是自動添加一個類到圖像標籤嵌入列表中?下面是我的代碼,其中itemvisiblein函數基本上打印到某個div。

我該如何清除活動名稱的所有類,然後將該數字添加到該特定行的圖像標記中? (相同的類字幕是目前)(因此,如果圖像3被選擇然後添加「活性」來表示代碼3列表行向下內嵌入所述圖像標籤。

乾杯,

<script type="text/javascript"> 
function itemVisibleIn(carousel, state){ 
    $("#gallerydescription").html(carousel.first); //currently displays image number// 

}; 

jQuery(document).ready(function() { 
    jQuery('#mycarousel').jcarousel({ 
    easing: 'backout', 
     animation: 1000, 
    vertical: true, 
     scroll: 1, 
    itemVisibleInCallback: itemVisibleIn, 
     }); 
}); 

<ul id="mycarousel" class="jcarousel jcarousel-skin-tango"> 
     <li><a href="images/gallery/placeholder1.png" rel="shadowbox" title="This is the description"><img class="caption" src="images/gallery/placeholder1.png" width="750" height="450" title="test Title1" alt="This is the title" /></a></li> 
     <li><a href="images/gallery/placeholder1.png" rel="shadowbox" title="This is the description"><img class="caption" src="images/gallery/placeholder1.png" width="750" height="450" title="test Title1" alt="This is the title" /></a></li> 
     <li><a href="images/gallery/placeholder1.png" rel="shadowbox" title="This is the description"><img class="caption" src="images/gallery/placeholder1.png" width="750" height="450" title="test Title1" alt="This is the title" /></a></li> 

因此,在短期

)獲得哪一行正被用於該圖像(列表行) )清除所有先前的活動類 )添加類活性到圖像噸ag類(以及標題)

回答

1
$("img.caption").eq(index).addClass("extraClass");