Reputation:
I'd like to switch pictures on mouse over, and revert on mouse leave. Can this be done?
Upvotes: 1
Views: 997
Reputation: 17390
$('#img').hover(function () {
$(this).data('old-src', $(this).attr('src')).attr('src', 'http://example.com/new_image.jpg');
}, function () {
$(this).attr('src', $(this).data('old-src'));
});
Upvotes: 2
Reputation: 6200
Try this, it works for me:-
$("div#test > img").mouseover(function(){
$(this).attr('src', 'http://www.google.co.uk/images/logos/ps_logo2a_cp.png');
});
$("div#test > img").mouseout(function(){
$(this).attr('src', 'http://www.google.co.uk/intl/en_ALL/images/logos/images_logo_lg.gif');
});
Upvotes: 1