大家好我有这个脚本,我希望当我点击其他.circle
不透明度时返回默认值1
$(this).find('.circle').click(function(){
$(this).animate({"opacity":"0"},200);
});
答案 0 :(得分:2)
您可以在制作动画之前将所有.circle
元素的不透明度设置为1
。例如:
$(this).find('.circle').click(function(){
$('.circle').css( 'opacity', '1' );
$(this).animate({"opacity":"0"},200);
});
答案 1 :(得分:1)
试试这个:
var $circles = $(this).find('.circle');
$circles.click(function(){
$circles.animate({"opacity":"1"},200);
$(this).animate({"opacity":"0"},200);
});
修改:清理代码
答案 2 :(得分:1)
发布的解决方案会导致当您单击选定的圆圈时,它会闪烁。
如果你想点击一个选定的圆圈,它就不会闪烁,只有当你从一个圆圈切换到另一个圆圈时才会发生变化试试这个:
$(this).find('.circle').click(function(){
if (!$(this).hasClass('current')){
$('.circle.current').animate({"opacity":"1"},200);
$('.circle').removeClass('current');
$(this).addClass('current');
$(this).animate({"opacity":"0"},200);
}
});