16进制颜色值转RGB
<script><br />
function hexToR(h) {<br />
return parseInt((cutHex(h)).substring(0, 2), 16)<br />
}<br />
function hexToG(h) {<br />
return parseInt((cutHex(h)).substring(2, 4), 16)<br />
}<br />
function hexToB(h) {<br />
return parseInt((cutHex(h)).substring(4, 6), 16)<br />
}<br />
function cutHex(h) {<br />
return h.charAt(0) == "#" ? h.substring(1, 7) : h<br />
}<br />
function setBgColorById(id, sColor) {<br />
var elems;<br />
if (document.getElementById) {<br />
if (elems = document.getElementById(id)) {<br />
if (elems.style) elems.style.backgroundColor = sColor;<br />
}<br />
}<br />
}<br />
</script>
JavaScript原生16进制颜色值转RGB值