I'm trying to temporarily change the contents of a div
on hover, using this jQuery:
$(document).ready( function() {
var $ratingHtml = '';
$('.userRating').hover(
function() {
$ratingHtml = $(this).html();
alert($ratingHtml);
$(this).html( 'Log in to rate' );
},
function() {
alert($ratingHtml);
$(this).html( $ratingHtml );
}
);
});
However on hover, the alert appears twice - first for the original HTML content, then again for the string 'Log in to rate'. It seems like a second mouseover event occurs. How can I work around this?