Currently I trying to check the mousehover on the Image, if mouse is pointing on the image then it will take another image to replace the original image
here is my code:
You did not handle the hover event well. Do this;
var sourceSwap = function () {
var $this = $(this);
var newSource = $this.data('alt-src');
$this.data('alt-src', $this.attr('src'));
$this.attr('src', newSource);
}
$('img[data-alt-src]').hover(sourceSwap);
Also, place it inside a document ready event to make sure all the dom is fully loaded before attaching the event like this;
$(document).ready(function(){
.....Your codes here
});