我想讓圖像可見,如果點擊索引的縮略圖匹配隱藏圖像的索引。我不確定我是否在正確的軌道上。我的代碼的第一部分,添加一個類'lght-box'加上它的索引正在工作。第二部分我遇到了麻煩。.each()jQuery和點擊
在此先感謝。
var brigZoom = {
init : function() {
var ground = $('.ground-box');
var lightBox = $('.lght-box img');
lightBox.each(function(index) {
$(this).addClass('lght-box' + index);
});
ground.hide();
lightBox.css('visibility', 'hidden');
var thumbImages = $('.thumbs img');
thumbImages.each(function(index){
$this = $(this);
$this.on('click', function(){
lightBox[this.index].css('visibility', 'visible');
});
});
}
};
brigZoom.init();
HTML:
<div class="ground-box"></div>
<div class="lght-box">
<img src="images/zoom/musings/small/1.jpg" class="images-that-need-zoom" alt="Honor & Beluga" />
<img src="images/zoom/musings/small/2.jpg" class="images-that-need-zoom" alt="" />
<img src="images/zoom/musings/small/3.jpg" class="images-that-need-zoom" alt="" />
<img src="images/zoom/musings/small/4.jpg" class="images-that-need-zoom" alt="" />
<img src="images/zoom/musings/small/5.jpg" class="images-that-need-zoom" alt="" />
</div>
這個工作,幫助我對這個問題的理解。謝謝。 – AaronHappe
@AaronHappe很好,歡迎您。 – undefined