【问题标题】:Jquery change border style on all specify divsJquery更改所有指定div的边框样式
【发布时间】:2014-01-17 14:25:51
【问题描述】:

当我使用此功能单击 div 时,我想更改它的边框颜色,但是当我单击 3 个 div 之一时,边框颜色要亮得多。

每个边框都会褪色,但只有活动的不会。为什么?

这是我的小提琴:Fiddle Demo

$('.re').click(function() {
    $('.re').removeClass('active').removeAttr('style');
    $(this).addClass('active');
});



$(".test1").click(function() {
    $(".mainNavitem").stop().animate({"border-right-color":"rgba(255,255,255, 0.2)"}, 800);
    $(".active").stop().animate({"backgroundColor":"transparent"}, 800);
    $(".bg").stop().animate({"backgroundColor":"rgb(199, 55, 59)"}, 800);

    });

$(".test2").click(function() {
    $(".mainNavitem").stop().animate({"border-right-color":"rgba(255,255,255, 0.5)"}, 800);
    $(".active").stop().animate({"backgroundColor":"transparent"}, 800);
    $(".bg").stop().animate({"backgroundColor":"rgb(199, 55, 59)"}, 800);
});

$(".test3").click(function() {
    $(".mainNavitem").stop().animate({"border-right-color":"rgba(255,255,255, 1)"}, 800);
    $(".active").stop().animate({"backgroundColor":"transparent"}, 800);
    $(".bg").stop().animate({"backgroundColor":"rgb(199, 55, 59)"}, 800);
});

【问题讨论】:

    标签: javascript jquery


    【解决方案1】:

    使用背景色代替背景色。并且动画到透明不能正常工作。看看这个帖子jQuery animate to transparent

    如果这样可以解决问题,您可以将动画设置为白色。像这样: http://jsfiddle.net/YngEE/5/

        $(".active").stop().animate({"background-color":"#fff"}, 800);
    

    【讨论】:

      猜你喜欢
      • 2013-07-23
      • 2011-09-26
      • 2023-04-03
      • 1970-01-01
      • 2013-08-17
      • 2013-11-04
      • 1970-01-01
      • 2014-01-22
      • 1970-01-01
      相关资源
      最近更新 更多