// 将颜色十改变成十六 function rgbToHex(r, g, b) ... { var r_string = r.toString(16); var g_string = g.toString(16); var b_string = b.toString(16); r_string = (r_string.length < 2) ? ("0" + r_string): r_string; g_string = (g_string.length < 2) ? ("0" + g_string): g_string; b_string = (b_string.length < 2) ? ("0" + b_string): b_string; return ("#" + (r_string + g_string + b_string).toUpperCase()); }