I had the same issue the other day. Oddly enough, it seemed to be OK in FF, but would flicker in IE, Chrome, and sometimes Safari. The solution is to use a css sprite sheet. You create an image that has both backgrounds next to each other. You only show a portion of the background sheet. you toggle it by adjusting the margin on the background. You can handle the margin adjustments using addClass and removeClass. Below is code, see here for a fiddle: http://jsfiddle.net/fMhMY/
CSS
.navButton span{
width:32px;
height:32px;
display:block;
}
a.leftButton span, a#leftButton span{
background-image:url(Prev.png);
background-position:-64px 0px;
}
/*nav button sprites */
/*sprite order is pushed, hover, natural */
a.leftButton.navOver span, a.rightButton.navOver span{
background-position:-32px 0px;
}
a.leftButton.navPressed span, a.rightButton.navPressed span{
background-position:0px 0px;
}
HTML
<div style='display:inline-block'>
<a href="javascript:void(0);" class="leftButton navButton" id='lefty'>
<span></span>
</a>
</div>
jQuery
$('.leftButton').mousedown(function() {
$('.leftButton').addClass('navPressed');
console.log('mousedown');
});
$('.leftButton').mouseup(function() {
$('.leftButton').removeClass('navPressed');
console.log('mouseup');
});
$('.leftButton').hover(function() {
$('.leftButton').addClass('navOver');
console.log('hover');
});
$('.leftButton').mouseout(function() {
$('.leftButton').removeClass('navPressed').removeClass('navOver');
console.log('mouseout');
});