Marian
Marian

Reputation: 7472

changing browser dependent css style from javascript

I have a css style like:

    button.gradient {
        background: -moz-linear-gradient(top, #00ff00 0%, #009900 50%, #00dd00);
        background: -webkit-gradient(linear, left top, left bottom, from(#00ff00), color-stop(0.50, #009900), to(#00dd00) );
    }

It is a green button with gradient background color. How can I change the background color from green to blue using javascript while keeping the gradient effect?

Upvotes: 0

Views: 104

Answers (1)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324610

Neither Firefox nor Chrome use the prefixed version any more, and haven't for quite some time.
Source: http://caniuse.com/#search=gradient

So make your life easier, just use the correct syntax:

background-image: linear-gradient(to bottom, #0f0, #090, #0d0);

Then you can simply change the gradient as desired.

Upvotes: 1

Related Questions