chris
chris

Reputation: 85

set background color in javascript

I have been trying to figure this out but it seems no matter how hard I try, I cannot seem to get it right. I have a mapview with the coordinates of the shape of a star. The star changes color on hover and opens a link on click. How do you set the background color? (not on hover color, i got that. just the main. Code:

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;
    });


}

Everything I try I just get errors. :(

Upvotes: 0

Views: 267

Answers (2)

Adam Tomat
Adam Tomat

Reputation: 11506

If you are using jquery ui 1.9+ then try using backgroundColor instead of fill

Upvotes: 1

Yatrix
Yatrix

Reputation: 13775

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

should do it.

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

Upvotes: 0

Related Questions