转换CSS中常用的颜色编码

来源:互联网 发布:奥斯曼土耳其知乎 编辑:程序博客网 时间:2024/05/17 22:33
    function toRGB(color) {        var regx = /^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/;//两位一次16进制转换        match = color.match(regx);        alert(match?parseInt(match[1],16)+','+parseInt(match[2],16)+','+parseInt(match[3],16):color+'=>is not color');    }    toRGB('#ffffff');