I'm pretty new to web dev so I'm currently working on a project to learn more JS. I'm trying to add a toggle function on a speaker icon as I want it to change/toggle its src from its normal state to the muted state (change the image src).
I know how to make it change once but I cannot change it back to its original state.
The code looks something like this:
<div class="tooltip" id="speakerbtn"><img src="images/images/speaker-icon.png" class="header-nav-button" id="myImage">
<span class="tooltiptext">Sound</span>
</div>
let image = document.getElementById('myImage');
image.addEventListener('click', function(){
changeImage();
});
function changeImage(){
image.src = 'images/images/volume-mute-icons.png';
}