不能让“不”起作用。当我单击一个列表时,我希望使用该索引来锁定一个绝对图像列表。存储在列表中的选定背景图像不会淡出,但其余的将消失。被选中的人会留下来。
$('.accordion-item').click(function(){
var index=$(this).index();
var rotationImage = $('.image-rotation li');
rotationImage.not('eq(index)').fadeout;
rotationImage.eq(index).fadeIn();
});Codepen:http://codepen.io/rezasan/pen/oLPYVr
发布于 2016-08-02 08:48:12
好吧,让我看看..。
:eq()而不是eq()index of :eq()”中转义.fadeOut()而不仅仅是.fadeout总的来说,其他的一切都很好。:)
$('.accordion-item').click(function(){
var index = $(this).index();
var rotationImage = $('.image-rotation li');
rotationImage.not(':eq('+ index +')').fadeOut();
rotationImage.eq(index).fadeIn();
});为了完成这个任务,您甚至可以在一个单链中完成这个任务,而根本不需要not():
$('.accordion-item').click(function(){
$('.image-rotation li').fadeOut().eq($(this).index()).fadeIn();
});工作的例子。 (更新代码)
https://stackoverflow.com/questions/38715656
复制相似问题