I've run into a strange problem with Javascript/jQuery. I need to update background color with the HSL color model using function written below:
function updateColorPreviewHSV(hsv){
var hue = Math.round(hsv.getHue(), 0);
var saturation = Math.round(hsv.getSaturation()*100, 0);
var value = Math.round(hsv.getValue()*100, 0);
var hsvText = "hsl("+hue+","+saturation+"%,"+value+"%)";
console.log(hsvText);
$("#pickedColor").css({"background": hsvText });
}
Given output is fine, but it doesn't change background color. Example outputs from hsvText variable:
hsl(336,74%,100%)
hsl(340,73%,100%)
hsl(343,73%,100%)
hsl(307,73%,100%)
Change comes only when I type values manually into variables, like below:
function updateColorPreviewHSV(hsv){
var hue = 100;
var saturation = 70;
var value = 40;
var hsvText = "hsl("+hue+","+saturation+"%,"+value+"%)";
console.log(hsvText);
$("#pickedColor").css({"background": hsvText });
}
and it works. So - why first function doesn't want to work properly? Where have I made mistake?