views:

124

answers:

1

Defining gradients in CSS works fine, but when I try to do this with jQuery, nothing changes. Typing

$('#header').css({background: '-webkit-gradient(linear, 0% 0%, 100% 100%, from(#cfc), to(#afa)'});

in Chrome's (4.0.249.43, Linux) JS console (in page's script tag too) really does nothing (but returns jQuery object, so it's valid). Tried replacing background with 'background', 'background-image', etc. - nothing works. But it works with single color like '#00ff00'.

Is this a bug in WebKit/V8/Chrome? Or I need to enter something different?

+3  A: 

Don't know if this is your problem or a typo in your question but you missed the closing parenthesis:

$('#header').css({background: '-webkit-gradient(linear, 0% 0%, 100% 100%, from(#cfc), to(#afa))'});

Notice the ending to(#afa))'}); instead of to(#afa)'});

Edit: Just tested in the javascript console in Chrome and it worked fine (although those two colors are so close that it looks like a solid background instead of a gradient).

Rob Van Dam
Yes, this is a typo :) Thanks.
myfreeweb