var elem = document.getElementById(*!*classID*/!*).src = "gun.jpg";
<img … onclick="func(this)" />
function func(element) { element.src = "…"; }