How can I swap an image’s SRC attribute, on click of that image?
<a href="#">
<img src="./layout/images/search.png" />
</a>
$('img[src="./layout/images/search.png"]').click(function () {
$(this).attr('src',"./layout/images/search_select.png")
});
You can try this solution:
As David Hedlund points out this will change all images on a page due to the
imgselector. You could target an image using a class as sam152 suggests or, you could target an image using it’ssrcattribute –See my demo – JSFiddle