My style sheet specifies:
.side-grad {
background: linear-gradient(to top, #ffdd00 0%, rgba(255, 221, 0, 0) 40%, rgba(255, 221, 0, 0) 100%);
}
I'd like to overwrite this color getting the input from a color picker input#color-gradient using jquery. My understanding is that I can use decimal or hex code for the rgb component of rgba(), so I type this into my console:
>> colorGradient = $("#color-gradient").val()
"#ff00cc"
>> $(".side-grad").css("background",(
"linear-gradient(to top,"
+ colorGradient
+ " 0,rgba("
+ colorGradient
+ ",0) 40%,rgba("
+ colorGradient
+ ",0) 100%)"
)
);
Object { 0: <div.side-grad>, 1: <div.side-grad>, length: 2, prevObject: Object, context: HTMLDocument → example.html, selector: ".side-grad" }
No error is thrown, but visually nothing changes. If I set `background: #ff00cc" there's no problem and the color changes as anticipated. What am I screwing up?
cssclasses, then you can switch over. usingaddClassandremoveClass.side-gradis already the dynamic css class.