I am attempting to use jQuery 3 to modify the CSS of a class and change the background color.
My first step is converting an rgba color code (properties.color) to a hexadecimal code, which is functioning correctly.
Next, I try to change the background color of the "zu-default div" class using jQuery. However, when I use the variable "finalcolor", the change does not take effect. Strangely, if I hardcode a hexadecimal color like "#fec23b", the change is visible. When I check the console, it confirms that the variable finalcolor contains a valid hexcode.
Any suggestions on what may be causing this issue?
// convert rgba to hex
let finalcolor = rgb2hex(properties.color);
// print the converted hexadecimal value (e.g. #fec23b)
console.log(finalcolor);
// should change the background of the zu-default div class to the color specified in "finalcolor"
$('.zu-default div').css("background", finalcolor);