I have defined a constant with hexadecimal color code like this:-
var textboxModifySuccessColor = '#E7FBBD';
In my JS code, I am using this variable to set the background-color using jQuery css method like this:-
$(this).find('option:selected').css('background-color', textboxModifySuccessColor);
But, When I am trying to retrieve the same using css
method I am getting it in rgb
format like this:-
rgb(10, 36, 106)
I have used the function mentioned in this thread & this one too but it is returning #0A246A
instead of #E7FBBD
. I have also tried the CSS Hooks solution but it is returning me highlight
. What I should do to get exactly the same color in hexadecimal format i.e. #E7FBBD
?
P.S.- It was working fine in IE 7, but this problem started with IE 11.
Update:-
I have reviewed my code again and found that the conversion by the method given is perfect, the problem is while rendering the code itself, I have printed the hexadecimal color(as I have defined) and it's rgb equivalent (as rendered by browser) onto the console like this:-
console.log("Before-" + textboxModifySuccessColor);
$(this).find('option:selected').css('background-color', textboxModifySuccessColor);
console.log("AfterSet-" + $(this).find('option:selected').css('background-color'));
This is giving me below ouput:-
Before-#E7FBBD
AftreSet-rgb(10, 36, 106)
But, When I tried converting the E7FBBD
hexadecimal code using this, the actual rgb should be : rgb(231,251,189)
. Is the browser rendering it wrong?
Here is my JS code:-
$(document).delegate('.myDDlClass', 'change', function () {
var currentRow = $(this).closest('tr');
var someText= $.trim(currentRow.find('td select.clsTest').val());
$(this).closest('tr').find('td select.clsTest').css("background-color", textBoxOriginalBackgroundColor);
$(this).find('option').css('background-color', textBoxOriginalBackgroundColor);
if (someText!= SelectDefaultValue) {
$(this).find('option:selected').css('background-color', textboxModifySuccessColor); //Problem here
}
});