js 判断颜色是否为深色 阀值
时间:2017-02-24 11:57:06
收藏:0
阅读:1131
//获取RGB值 颜色深用白色 颜色浅则用黑色
var RgbValue = this.style.backgroundColor.replace("rgb(", "").replace(")", "");
var RgbValueArry = RgbValue.split(",");
var $grayLevel = RgbValueArry[0] * 0.299 + RgbValueArry[1] * 0.587 + RgbValueArry[2] * 0.114;
$this.addClass("color_curr");
if ($grayLevel >= 192) {
$this.html(‘<p class="fa fa-check color_black"></p>‘);
} else {
$this.html(‘<p class="fa fa-check color_withe"></p>‘);
}
原文:http://www.cnblogs.com/qinwei/p/6437800.html
评论(0)