-1

我需要在div不淡化文本容器的情况下淡化 a 的文本。这是我的工作。我需要第 8 行像当前第 7 行一样工作,这样我就可以删除文本周围的容器div( )。content换句话说,我需要div在点击时为 a 的文本的颜色变化设置动画。有任何想法吗?

$(document).ready( function(){
    var x = false;
    $('#changeWidth').click(function() {
        if(x){}
        else{
            x = true;
            $(".content").fadeToggle(300);
            //$("#changeWidth").html().fadeToggle(300);
            var toggleWidth = $(".inner").width() == 30 ? "350px" : "30px";
            var toggleHeight = $(".inner").height() == 10 ? "48px" : "10px";
            $('.inner').animate({ width: toggleWidth, height: toggleHeight });
            setTimeout(function(){x=false;},500);
        }
    });
});

提前致谢

编辑:几个月后回顾这个问题,这就是我使用 CSS 过渡和切换的方式

4

1 回答 1

2

小提琴。这符合您的需求吗?你可以这样做:

HTML:

<p class="toHide">jQuery</p>

JS:

$('.toHide').click(function(){
    $(this).css('color', 'white');
});

如果你想使用动画的颜色,你必须包括这个插件:https ://github.com/jquery/jquery-color

$('.toHide').click(function(){
    $(this).animate{(color: 'white'), 50};
});

或者您可以将 toggleClass() 与 CSS 转换一起使用!!(这是最好的选择!!):

$('.toHide').click(function(){
    $(this).toggleClass('colorWhite');
});
于 2013-06-11T17:02:39.930 回答