I have a array(dynamic values) with hex colors and I want put the font color black for the light backgrounds and color White for the dark backgrounds
/* array for example */
var colorHexCode = ["#ECECEC", "#FFF", "#F4F2ED"];
for (var i = 0; i < colorHexCode.length; i++) {
var ColorLayerDiv = document.createElement("div");
ColorLayerDiv.style.height = "10px";
ColorLayerDiv.style.backgroundColor = colorHexCode[i];
$('#Layers').append(ColorLayerDiv);
}
I want set the font color automatic like this:
Is it possible to do this using js or query? if yes can you show me an example