【问题标题】:I would like to animate a CSS change using .attr to change the link我想使用 .attr 为 CSS 更改设置动画以更改链接
【发布时间】:2013-12-14 20:19:38
【问题描述】:

我有这段脚本来更改 CC,但更改是即时的,我想对其进行动画处理(使其平滑),知道如何实现吗?

脚本:

$(document).ready( function(){
    var css = 'x';
    $('#button').button();
    $('#button').click( function() {
        if (css == 'x') {
            $('#button').button('option', 'label', 'change to css x');
            $('link[href="css/x.css"]').attr('href', 'css/y.css');
            css= 'y';
        }
        else if (css== 'y') {
            $('#button').button('option', 'label', 'change to css y');
            $('link[href="css/y.css"]').attr('href', 'css/x.css');
            css= 'x';           
        }
    });
});

【问题讨论】:

    标签: jquery jquery-animate attr


    【解决方案1】:

    这可能被认为是不好的做法,但您可以尝试临时添加:

    * {
        transition: all ease-in-out 1s;
    }
    

    然后,执行您的 CSS 更改,然后删除此规则。

    我没有测试它,它可能根本不起作用。只是一个想法。

    【讨论】:

      猜你喜欢
      • 2012-06-18
      • 1970-01-01
      • 2021-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-15
      • 1970-01-01
      相关资源
      最近更新 更多