CSS渐变描述here,但我不知道如何在JavaScript中选择这些属性。如果可能的话,我宁愿不使用jQuery。我该如何去设置JavaScript中的CSS渐变背景?
编辑:只是执行以下操作似乎并没有工作...
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)";
似乎工作:HTTP: //jsfiddle.net/B6sEr/(Chrome 19,Firefox 13)。 –
对于普通的JavaScript解决方案,请参阅:http://stackoverflow.com/a/15071347/1306809 –