I understood why this script did not work in IE10 !: D
There are two reasons:
When you call this code:
var oldCol = $(this).css("background-color");
IE first returns a hexadecimal value (in this case #8be79c )
Then subsequent calls to the script return the value rgb ( rgb(139,231,156) ) (note the absence of spaces). Is it right?
When I originally wrote the script, I used alert() to find out what color was returned by .css() , which rgb(139, 231, 156) gave me (from Chrome with a space!) So that the script would look.
Replacement:
var oldCol = $(this).css("background-color"); if (oldCol == "rgb(139, 231, 156)") {
WITH
var oldCol = $(this).css("background-color").replace(/ /g,''); if (oldCol == "rgb(139,231,156)" || oldCol == "#8be79c") {
means that it now works all the time in both Chrome and IE 10.
Hope this helps anyone facing this rather unusual issue.
Thanks for the helpful comments about debugging, it helped me sort out the problem!
source share