iLemming
iLemming

Reputation: 36264

jQuery css gradient

To have a gradient background on an element I do something like this:

.css('filter','progid:DXImageTransform.Microsoft.gradient(startColorstr=\'#FFFFFF\', endColorstr=\'#'+event.backgroundColor+'\', gradientType=1)')
.css('background-image','-webkit-gradient(linear, left top, right bottom, color-stop(0.1, #FFFFFF), color-stop(0.99, #'+event.backgroundColor+'))')
.css('background-image','-moz-linear-gradient(top left, #FFFFFF 0%, #'+event.backgroundColor+' 100%)')
.css('background-image','-o-linear-gradient(top left, #FFFFFF 0%, #'+event.backgroundColor+' 100%)')

Now, isn't jQuery suppose to eliminate all the work related to cross-browser compatibility issues? is there any better way to do that. Without using any additional plugins?

Upvotes: 8

Views: 17171

Answers (2)

NakedLuchador
NakedLuchador

Reputation: 991

there is a jQuery plugin used to work with gradient. i have never used it but it looks simple

http://plugins.jquery.com/project/gradient

heres how to use it :

http://www.julien-verkest.fr/13/11/2007/jquery-gradient-le-plugin-qui-permet-de-creer-dynamiquement-des-backgrounds-degrades

or you could use use Gradientz

http://jquerystyle.com/2009/08/06/gradientz

Gradientz looks even more complete and easy to use. Up to you good luck buddy.

Upvotes: 8

Zirak
Zirak

Reputation: 39848

Nope. jQuery doesn't have a native implementation of vendor-prefixes. Not very surprising, too; jQuery is a JavaScript library, designed to make JavaScript cross-browser.

Check out CSS3 Finalize for a plugin.

Upvotes: 4

Related Questions