Returning name of colors using jQuery

前端 未结 1 665
日久生厌
日久生厌 2020-12-21 12:25

CSS:

.red-tile-color{
    background-color:red;
    color:white;
}

JS:

var colorName = $(\".red-tile-color\").css(\"color\"         


        
相关标签:
1条回答
  • 2020-12-21 12:57

    It's going to be messy trying to get a name from the rgb value. I would instead encourage you to use the jQuery Color plugin to determine whether the current color is a particular value or not:

    if ( $.Color( colorName ).is( "red" ) ) {
        /* Do X */
    } else {
        /* Do Y */
    }
    
    0 讨论(0)
提交回复
热议问题