I\'ve thought about the following for a while already, so now I want to know your opinions, possible solutions, and so on.
I am looking for a plugin or technique tha
By combining the answers [ @alex-ball , @jeremyharris ] I found this to be the best way for me:
$('.elzahaby-bg').each(function () {
var rgb = $(this).css('backgroundColor');
var colors = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
var r = colors[1];
var g = colors[2];
var b = colors[3];
var o = Math.round(((parseInt(r) * 299) + (parseInt(g) * 587) + (parseInt(b) * 114)) /1000);
if(o > 125) {
$(this).css('color', 'black');
}else{
$(this).css('color', 'white');
}
});
*{
padding: 9px;
}
color is white
color is black
color is black
color is white