I am attempting to write an simple function in an HTML page which displays the image and there are few buttons which change the image I have used the "document.getElementById('myImage').src= " command to change it but there is no image shows after I click the image. The same image is loading properly using the tag. The same button works if I use a link direct taken from google. Below I have pasted the code. Any suggestions are appreciated.
<!IDOCTYPE HTML>
<html>
<body>
<h2> This page shows changing emotions using various buttons </h2>
<img id = "image" src = "path\angry.jpg" style = "width:100px">
<button onclick = 'document.getElementById("image").src = "path\envy.jpg"'>Envy</button>
<button onclick = 'document.getElementById("image").src = "path\angry.jpg"'>Angry</button>
<button onclick = 'document.getElementById("image").src = "path\sad.jpg"'>Sad</button>
<button onclick = 'document.getElementById("image").src = "path\embarassed.jpg"'>Embarassed</button>
<button onclick = 'document.getElementById("image").src = "path\happy.jpg"'>Happy</button>
<button onclick = 'document.getElementById("image").src = "path\anxiety.jpg"'>Anxiety</button>
</body>
</html>
Tried links from Google it works but local images does not work in the on click function Thank you!