Javascript - Get image source and replace the source of another image

Details To get the source of an image, you could use the "onclick" event:


<img onclick="setImg(this.src);" src="/example.jpg" />



This will call the function "setImg" and give it the source of this object: "example.jpg"
Now, to overwrite the source of another image with the source of this image, you could use the following function for "setImg":



	<script type="text/javascript">

	    function setImg(a){

	          document.getElementById('ImageFrame').src =  a

	     }

	</script>


You need a image somewhere in your html code with the id "ImageFrame".