I am trying to make a function to toggle an image src when a button (another image) is clicked... This is what I have so far, and it doesn't work. It does work when you adapt it to change other properties of the image, such as width, but not the src... any ideas of what could be wrong?
var el = document.getElementById(obj);
el.src= (el.src== "a.png" ? "b.png" : "a.png") ;
<img id="im" src="a.png">
<img src="button.png" onclick="click('im')" >