[jQuery] jQuery Image Swap Works in FF, not IE
Hi all,
I have a little jQuery function that toggles a window on click and
changes the background image of a span (to toggle an up/down arrow).
It works fine in FF, but in IE, it is delayed. For example, in IE, you
click once and the arrow stays the same (in the closed position). When
you click to close the toggled window (the 2nd click), the arrow
finally swaps to the down/toggled position, even though it's the 2nd
click and the window has now been closed. The arrow continues in this
"off by one" patten indefinitely, but only in IE. Any suggestions?
Here is the code:
$(document).ready(function() {
$('span.BodyCopy12jQuery').click(function() {
var host = window.location.hostname;
var currImage = $(this).css('backgroundImage');
var id = $(this).attr('id');
$('#faqAnswer' + id).toggle();
$(this).css({backgroundImage: currImage == 'url(http://' + host + '/
images/arrow_red_right.gif)' ? 'url(http://' + host + '/images/
arrow_red_down.gif
)' : 'url(http://' + host + '/images/arrow_red_right.gif)'});
return false;
});
});
Thanks.