You'll understand my problem after seeing my jsfiddle ;) : http://jsfiddle.net/N_3G/L47h985u/
Everything runs fine except that if you click on an active thumb, the fadeOut/fadeIn process is launched :( !...
I just want to complete this feature by saying "If the current thumb is active, when you click on it, do nothing..."
I'm beginner in jQuery and I'm trying to do my best.
Thanks for reading. Nicolas.
<div id="xmas-slides-wrapper">
<div id="xmas-slide">
<div id="slide1-ban" class="slides">
<img src="http://lorempixel.com/550/200/sports/1" />
</div>
<div id="slide2-ban" class="slides active">
<img src="http://lorempixel.com/550/200/sports/2" />
</div>
<div id="slide3-ban" class="slides">
<img src="http://lorempixel.com/550/200/sports/3" />
</div>
<div id="slide4-ban" class="slides">
<img src="http://lorempixel.com/550/200/sports/4" />
</div>
</div>
<div id="thumb-select">
<div class="thumb" id="slide1">
<img src="http://lorempixel.com/100/100/sports/1" />
</div>
<div class="thumb active" id="slide2">
<img src="http://lorempixel.com/100/100/sports/2" />
</div>
<div class="thumb" id="slide3">
<img src="http://lorempixel.com/100/100/sports/3" />
</div>
<div class="thumb" id="slide4">
<img src="http://lorempixel.com/100/100/sports/4" />
</div>
</div>
</div>
And the JS :
$('.slides.active').show();
$('.thumb').each(function() {
$(this).click(function() {
if ($(this).not('.active')) {
$('.thumb.active').removeClass('active');
$(this).addClass('active');
var thumbActif = $(this).attr('id');
$('.slides.active').fadeOut('slow');
$('.slides.active').removeClass('active');
$('#' + thumbActif + '-ban').addClass('active');
$('.slides.active').fadeIn('slow');
}
});
});
A bit of CSS :
#xmas-slides-wrapper {
position:relative;
height:250px;
width:550px;
text-align:center;
}
#xmas-slide {
margin-bottom:20px;
height:200px;
width:550px;
overflow:hidden;
position:relative;
}
#xmas-slide .slides {
display:none;
position:absolute;
top:0;
left:0;
}
#thumb-select .thumb {
display:inline-block;
margin:0 10px;
}
#thumb-select {
position:absolute;
bottom:0;
left:0;
text-align:center;
width:100%;
}