在javascript中设置背景颜色

时间:2012-10-26 15:37:58

标签: javascript jquery colors background

我一直试图解决这个问题,但似乎无论我怎么努力,我似乎​​无法做到这一点。我有一个mapview与星形的坐标。星号会在悬停时更改颜色,并在点击时打开链接。你如何设置背景颜色? (不是悬停颜色,我得到了。只是主要。代码:

for (var country in onestar) {
    var obj = r.path(onestar[country].path);

    obj.attr(attributes);

    arr[obj.id] = country;



    obj
    .hover(function(){


    this.animate({
            fill: '#41464e'
        }, 300);
    }, function(){
        this.animate({
            fill: attributes.fill
        }, 300);
    })
    .click(function(){


    window.open('http://www.yahoo.com/')


    });

    $('.point').find('.close').live('click', function(){
        var t = $(this),
            parent = t.parent('.point');

        parent.fadeOut(function(){
            parent.remove();
        });
        return false;
    });


}

我尝试的一切我都会遇到错误。 :(

2 个答案:

答案 0 :(得分:1)

如果您使用的是jquery ui 1.9+ ,请尝试使用backgroundColor代替fill

答案 1 :(得分:0)

$('your selector').css('background-color','your color'); 

应该这样做。

http://api.jquery.com/css/

相关问题