ASP.NET Color Picker - Knowledge Base

« Back to Knowledge Base list

Get custom color title.

Q:

How can I get the custom color title by the hex value? I mean the client-side.

A:

Use this function:

function getColorTitle(color) {
  var hexColor = OboutInc.ColorPicker._colorToRgb(color);
  var divs = document.getElementsByTagName("div");
  for (var i = 0; i < divs.length; i++) {
     var div = divs[i];
     if (div.className == "ColorPicker_CustomButton_Div") {
        if (OboutInc.ColorPicker._colorToRgb(div.style.backgroundColor) == hexColor ) {
           return div.title;
        }
     }
  }
  return hexColor;
}