html image javascript src

Programmatically change the src of an img tag

How can I change the src attribute of an img tag using javascript?

<img src="" name=edit-save/>

at first I have a default src which is “” and I wanted to change it with “” onclick.

here’s my html onclick:

<a href="#" onclick='edit()'><img src="" id="edit-save"/></a>

and my JS

function edit()
var inputs = document.myform;
for(var i = 0; i < inputs.length; i++) {
inputs[i].disabled = false;

I’ve tried inserting this inside the edit(), it works but need to click the image twice

var edit_save = document.getElementById("edit-save");
edit_save.onclick = function(){
this.src = "";