I'm currently working on a Codepen project where I want to use JavaScript to change the image of an element with the id "chrome". However, my code doesn't seem to be working as expected. Can someone help me troubleshoot and fix this issue? Your assistance is greatly appreciated.
The main goal is to modify the image of an element with the id of "chrome" when it's clicked.
Below is the JavaScript code snippet that I have been using:
function changeImage() {
if (document.getElementById("chrome").src == "https://upload.wikimedia.org/wikipedia/commons/8/87/Google_Chrome_icon_%282011%29.png")
{
document.getElementById("chrome").src = "https://www.centerpointe.com/v2/wp-content/uploads/2014/01/red-x.png";
}
else
{
document.getElementById("chrome").src = "https://upload.wikimedia.org/wikipedia/commons/8/87/Google_Chrome_icon_%282011%29.png";
}
}
Essentially, I want to replace the chrome icon with an X image when it's clicked. Any insights on how to achieve this would be really helpful.