Prototype This page is part of the Prototype JavaScript framework documentation.
Overview | (...)

Number.prototype.toColorPart Returns the hexadecimal string representation of the number.

Syntax


  num.toColorPart();

Returns

The hexadecimal representation of num.

Example


 <script type="text/javascript">
   var red = 255;
   var green = 0;
   var blue = 0;
   var saturatedRedColor = '#' + red.toColorPart() + green.toColorPart() + blue.toColorPart();
   $('myLabel').style.color = saturatedRedColor;
 </script>

saturatedRedColor is equal to ’#ff0000’.

Notes

If the number is lower than 16, it will be prefixed by a leading zero.