I have a problem with my code where I change an image by clicking a button in HTML, but when I try to run the code in the console it says it my image.src is undefined.
This is my code in javaScript
var image = document.getElementById("sider").src="side1.jpg";
var image_tracker = "1"
function changeImage() {
if(image_tracker == "1") {
image.src="side2.jpg";
image_tracker = "2";
}
else image.src="side1.jpg";
}
And this is my HTML
<p>
<img id="sider" src="side1.jpg" style="width:450px;height:650px;">
</p>
<center>
<button type="button" onclick="changeImageBack()"> < </button>
<button type="button" onclick="changeImage()"> > </button>```
I haven't made the function for ```changeImageBack()``` yet, so ignore that.