Skip to content Skip to sidebar Skip to footer

Returning Name Of Colors Using Jquery

CSS: .red-tile-color{ background-color:red; color:white; } JS: var colorName = $('.red-tile-color').css('color'); Return: rgb(255, 255, 255); How do i return the name of

Solution 1:

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 */
}

Post a Comment for "Returning Name Of Colors Using Jquery"