日常练习之16进制颜色转换
1 function getRgb(x){ 2 var i,arr=[] 3 var getString=x.substring(1) 4 for(i=0;i<3;i++){ 5 arr[i]=parseInt(getString.substring(0,2),16) 6 getString=getString.substring(2) 7 } 8 return "rgb("+arr[0]+","+arr[1]+","+arr[2]+")" 9 } 10 getRgb("#00ff00")