rgba转16进制: function RGBToHex(rgb){ var regexp = /[0-9]{0,3}/g; var re = rgb.match(regexp);//利用正则表达式去掉多余的部分,将rgb中的数字提取 var hexColor = "#"; var hex = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']; for (var i = 0;…
原文地址:http://www.cnblogs.com/vaal-water/archive/2013/04/08/3008880.html 自己试过很好用 function zero_fill_hex(num, digits) { var s = num.toString(16); while (s.length < digits) s = "0" + s; return s; } function rgb2hex(rgb) { if (rgb.charAt(0) == '#'…