Unexpected String

- 1 answer

Ad

Can anyone help with this debug issue? Trying to take the variables and throw them in a Change for CSS to get the background to change into a gradient.

var gradientAlpha = "#999";
var gradientBravo = "#555";

$('#banner-gradient')
 .change(function() {
    $('.banner-gradient').css({'background': 'linear-gradient(135deg,' + gradientAlpha + ',' + gradientBravo ')'});
})
.change();
Ad

Answer

Ad

Missing a + after gradientBravo

gradientBravo is a variable which you trying to add to a string. So you should have + before and after.

$('#banner-gradient').change(function() {
    $('.banner-gradient').css({'background': 'linear-gradient(135deg,' 
                                         + gradientAlpha + ',' + gradientBravo+')'});
});
Ad
source: stackoverflow.com
Ad