//转换css中常用颜色编码 var toRGB = function (val){ var reg1 = /^#([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i; //i不区分大小写 var reg2 = /^#([0-9A-F])([0-9A-F])([0-9A-F])$/i; var reg3 = /[0-9A-F]{2}/g,//发现第一个匹配项即停止 m; if(reg2.test(val)){ val = val.replace(reg2,"#$1…