这是我正在处理的页面的(有点)工作版本:https ://www.the-car-club.com/walsergold/home.asp 。内容显示正常,但只有最后一张幻灯片上的内容是可点击的。关于如何使前几张幻灯片上的内容具有交互性的任何建议?
HTML
<div class="square-slider">
<div class="slide slide1">
<div class="content light">
<h3>Recreating The Square Slider</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac eros et augue vulputate
aliquet pellentesque vitae tortor. Pellentesque mi velit, euismod nec semper</p>
</div>
<img src="images/asset1.png" alt="" class="asset" />
</div>
<div class="slide slide2">
<div class="content dark">
<h3>Looks Amazing Right?</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac eros et augue vulputate
aliquet pellentesque vitae tortor. Pellentesque mi velit, euismod nec semper</p>
</div>
<img src="images/asset2.png" alt="" class="asset" />
</div>
<div class="slide slide3 inverted">
<div class="content light">
<h3>And Simple To Use</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac eros et augue vulputate
aliquet pellentesque vitae tortor. Pellentesque mi velit, euismod nec semper</p>
</div>
<img src="images/asset3.png" alt="" class="asset" />
</div>
<a href="#" class="prev">Prev</a>
<a href="#" class="next">Next</a>
<div class="overlay"></div>
JavaScript (jQuery)
(function($){
$('.square-slider').each(function(){
var slider = $(this),
slides = slider.find('.slide'),
currentSlide = 0;
slides.show();
$(slides[currentSlide]).addClass('active');
$('.next,.prev', slider).show();
$('.prev', slider).on('click', function(){
slides.removeClass('active');
currentSlide--;
if(currentSlide < 0) currentSlide = slides.length - 1;
$(slides[currentSlide]).addClass('active');
return false;
});
$('.next', slider).on('click', function(){
slides.removeClass('active');
currentSlide++;
if(currentSlide > slides.length - 1) currentSlide = 0;
$(slides[currentSlide]).addClass('active');
return false;
});
});
})(window.jQuery);