I want to replace an image when it is clicked using jQuery. Here is my code.
HTML
{% load static %}
<div class="col-md-6 image">
<img class="map" src="{% static 'home/map.png' %}" class="doctors">
</div>
jQuery
$(document).ready(function() {
$('.map').click(function() {
$(this).attr("src", "{% static 'home/map2.png' %}");
});
})
I tried the code above and it didn't work. The location of the image and its image format is already correct but when I click the image it only shows a blank picture (the same display as when we write the wrong image format).
I already tried to change the jQuery into this one too
$('.map').click(function() {
$(this).attr("src", "home/map2.png");
});
but it still didn't work. Anyone knows how to fix it?