In working to transition an image from grayscale to full color after a fixed time I encountered a problem with Jquery's interaction with CSS Transition and i'm not sure what the work around is supposed to be:
If I start out with the existing #globecont img { style and change the .globefc from a class to a #globefc:hover everything works fine. But when I use Jquery to apply it as a class after a delay - the "class" is added to the IMG properly, but no transition or change in the filter is occurring.
I have not yet tried using .trigger("hover") in place of .addClass() but regardless of if that works or not, can someone explain why this doesn't work as written?
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<style>
body {background-color:#000000;}
#globecont {position:relative; margin-left:auto; margin-right:auto; text-align:center;}
#globecont img {
filter: grayscale(100%);
-webkit-filter: grayscale(100%);
transition: 3s;
}
.globefc {
filter: grayscale(0%);
-webkit-filter: grayscale(0%);
filter: none;
}
</style>
</head>
<body>
<div id="globecont"><img src="http://philanthropicsandbox.org/wp-content/uploads/2012/12/Globe1.png" width="300" height="300" id="globe"></div>
<script>
$(document).ready(function() {
$('#globe').delay(500).addClass("globefc");
});
</script>
</body>
</html>