How would I go about setting a CSS gradient background in JavaScript?

Posted by Dan on Pro Webmasters See other posts from Pro Webmasters or by Dan
Published on 2012-06-24T06:25:33Z Indexed on 2012/06/24 9:23 UTC
Read the original article Hit count: 260

Filed under:
|

The CSS gradient is described here, but I have no idea how to select for these properties in JavaScript. I would rather not use jQuery for this if at all possible.

EDIT: Just doing the following doesn't seem to work...

document.getElementById("selected-tab").style.background = "#860432";
document.getElementById("selected-tab").style.background = "-moz-linear-gradient(#b8042f, #860432)";
document.getElementById("selected-tab").style.background = "-o-linear-gradient(#b8042f, #860432)";
document.getElementById("selected-tab").style.background = "-webkit-gradient(linear, 0% 0%, 0% 100%, from(#b8042f), to(#860432))";
document.getElementById("selected-tab").style.background = "-webkit-linear-gradient(#b8042f, #860432)";

© Pro Webmasters or respective owner

Related posts about JavaScript

Related posts about css3