I use a simple jquery fade slider on my page
HTML
<ul id="slider1" class="images-list">
<li style="background-image: url('Content/img/bg_10.jpg')"></li>
<li style="background-image: url('Content/img/bg_11.jpg')"></li>
<li style="background-image: url('Content/img/bg_12.jpg')"></li>
</ul>
<ul class="controls">
<li class="active"></li>
<li></li>
<li></li>
</ul>
jQuery
$.fn.slider = function () {
var $this = this;
var $controls = $this.nextAll('.controls').first();
var index;
$this.find('li:gt(0)').hide();
setInterval(function () {
$this.find('li:first-child').fadeOut('slow')
.next('li').fadeIn('slow')
.end().appendTo($this);
$controls.find('li').removeClass('active');
index = $this.find('li:visible').index();
$controls.find('li').eq(index).addClass('active');
},
4000);
};
我想将类“active”添加到当前控件,但是滑块中可见元素的位置每次都会改变,并且每次都是第一个元素。我该怎么做? http://jsfiddle.net/u9d3xa1q/11/