我有一個數組在我的js文件中加載圖像到html幻燈片放映和縮略圖導航。幻燈片img src每4秒與一個縮略圖src屬性相匹配。此時間基於setInterval。jQuery:addClass元素具有相同或匹配的來源
我想不斷檢查幻燈片img src是否與縮略圖img src匹配,然後向兩者添加一個active類。我已經能夠類添加到主幻燈片和所有的縮略圖,但我似乎無法只能夠將該類添加到只是對匹配的SRC的IMG元素屬性
<div class="slideshow">
<!-- this img src attribute changes on a setInterval and matches one of the .imageHolder img src attributes at a time. I would like to addClass to img elements that have the same src and remove when they no longer match-->
<img class="slideshowimg" alt="" src="imgs/slide3_470hx690w.jpg" style="opacity: 1;">
</div>
<div class="description" style="opacity: 1;">
<h2>LOREM IPSUM BLAH BLAH BLAH</h2>
<p>lorem ipsum blah blah blah</p>
<a href="#" class="btn readmore">Read More</a>
</div>
<a href="#" class="btn prev">Previous</a>
<a href="#" class="btn next">Next</a>
<div class="window">
<div class="imageHolder" style="width: 690px;">
<img src="imgs/slide1_470hx690w.jpg">
<img src="imgs/slide2_470hx690w.jpg">
<img src="imgs/slide3_470hx690w.jpg">
<img src="imgs/slide4_470hx690w.jpg">
<img src="imgs/slide5_470hx690w.jpg">
</div>
</div>
你也應該刪除其它元素的類時,你的類添加到匹配的元素。 –
顯示你的js代碼。 –