Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function AccessibleColor(el) {
- var backgroundRGB = el.css("backgroundColor");
- backgroundRGB = backgroundRGB.substring(backgroundRGB.length - 1, 4).replace(/\s/g, "").split(",");
- var sum = Math.round((
- (parseInt(backgroundRGB[0]) * 299) +
- (parseInt(backgroundRGB[1]) * 587) +
- (parseInt(backgroundRGB[2]) * 114)) / 1000);
- if (sum > 128) {
- el.style.color = "black";
- } else {
- el.style.color = "white";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement