jQuery
You could use the mouseover
and mouseout
events :
$("img").on({
"mouseover" : function() {
this.src = 'images/Market.png';
},
"mouseout" : function() {
this.src='images/tile_4.jpg';
}
});
This way you could take out the attributes onmouseout
and onmouseover
from you HTML and make your code neat.
CSS
However, the easiest way is using CSS:
img {
background-image: url('images/tile_4.jpg');
}
img:hover {
background-image: url('images/Market.png');
}