I'm building an employee bios page where the client wants selected thumbnails to display in color at full opacity and all others at lower opacity in black and white. Which wouldn't be hard - the trouble is, every thumbnail has to have a color state and a black and white state. So my next thought was to swap out the black and white image (which would be resting within the div with a color background image) on mouseover.
$('.thumbnail').mouseenter(function(){
var current = $(this); // cache thing
var thishtml = current.html(); // get contents of thing
current.html('').mouseleave(function(){ //empty the thing
current.html(thishtml); //put the variable back in the thing
});
});
My HTML would be as follows:
<div class = "thumbnail" style = "background-image: url(color.jpg);">
<img src="blackandwhite.jpg" />
</div>
Obviously, since I'm asking the question, my idea didn't work. The mouseover removes the innerHTML, and the variable is converted successfully, but it doesn't get inserted into the DIV again. What am I missing?