How can I change the src of an img tag to another img tag?
First I made an onclick on all the img tags that I want to switch from, and I made a function in javascript, and I put the src of all the images I want to switch from in a variable, and here is the code:
function click() {
var content = document.getElementById('img_1');
var img = document.getElementsByClassName('img_footer').src;
content.src = img;
}
and HTML :
<article>
<img src="_1.jpeg" id="img_1"/>
</article>
<div id="images">
<img src="_2.jpeg" class="img_footer" onclick="click()"/>
<img src="_3.jpeg" class="img_footer" onclick="click()"/>
<img src="_4.jpeg" class="img_footer" onclick="click()"/>
<img src="_5.jpeg" class="img_footer" onclick="click()"/>
<img src="_6.jpeg" class="img_footer" onclick="click()"/>
</div>
What I want is (when I click on one of the images, the src of the original image must be changed to the image that has been compressed)