how to get the the value of background-color property
if ($(this).css('background-color') == 'InfoBackground')
{
// it doesn't enter here
}
how to get the the value of background-color property
if ($(this).css('background-color') == 'InfoBackground')
{
// it doesn't enter here
}
You'll want to check against the RGB value of whatever InfoBackground
is.
Notice the following returns rgb(251, 252, 197)
if ($("#myElement").css('background-color') == 'rgb(251, 252, 197)') {
alert('hello');
}
<!-- language: lang-css -->
#myElement { background-color: InfoBackground; }
<!-- language: lang-html -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="myElement">Hi</div>
<!-- end snippet -->
However, this seems like kind of a fickle approach. Different browsers might behave differently or implement InfoBackground
differently. It would be better to assign a class, property, or data-attribute and then use that to dictate the color.