我这里有这个:
$('#slider li').click(function () {
var stepClicked = $(this).index();
alert(stepClicked);
if (stepClicked != 0) {
$('#cs_previous').removeClass('cs_hideMe');
} else {
$('#cs_previous').addClass('cs_hideMe');
}
$('li.cs_current').removeClass('cs_current');
$($(this)).addClass('cs_current');
moveToNextImage(stepClicked);
function moveToNextImage(stepClicked) {
alert(stepClicked);
var currentIs = $('li.cs_current').index();
var newLeftEdge = currentIs - stepClicked;
$('.cs_riskStageImage').fadeTo(200, .2).animate({
left: newLeftEdge
}, "fast").fadeTo(200, 1);
};
});
警报显示了单击的li的正确索引,并且当我在调用的最后一个函数内警报变量moveToNextImage(stepClicked)
时,相同的值就会显示出来,但动画却没有发生。这在许多其他方式中都有效,但我正在尝试传递被单击列表项的索引值以供计算使用。
...或者我可以将该值转换为第一个函数中的另一个变量,然后将其传递给第二个函数吗?
$($(this))
应该被改为$(this)
。 - gen_Eric