Heojju

[JavaScript] rgb to hex 본문

웹개발/JavaScript

[JavaScript] rgb to hex

우주별 2017. 6. 8. 15:19
if($(this).css("color")){
var rgbSplit = $(this).css("color").split("(")[1].split(")")[0];
rgbSplit = rgbSplit.split(",");
var hex = rgbSplit.map(function(x){
x = parseInt(x).toString(16);
return (x.length==1) ? "0"+x : x;
});
hex = hex.join("");
}else{
var hex = "FFFFFF";
}