1//change image src
2document.getElementById('myImageID').src="images/my_other_image.png";
1// Pure JavaScript to Create img tag and add attributes manually ,
2var image = document.createElement("img");
3var imageParent = document.getElementById("body");
4image.id = "id";
5image.className = "class";
6image.src = searchPic.src; // image.src = "IMAGE URL/PATH"
7imageParent.appendChild(image);
8
9// Set src in pic1
10document["#pic1"].src = searchPic.src;
11
12// or with getElementById
13
14document.getElementById("pic1").src= searchPic.src;
15
16// jQuery to archive this,
17$("#pic1").attr("src", searchPic.src);
18
1<script type="text/javascript">
2 function changeImage(a) {
3 document.getElementById("img").src=a.src;
4 }
5</script>
6<div id="main_img">
7 <img id="img" src="1772031_29_b.jpg">
8</div>
9<div id="thumb_img">
10 <img src='1772031_29_t.jpg' onclick='changeImage("1772031_29_b.jpg");'>
11 <img src='1772031_55_t.jpg' onclick='changeImage("1772031_55_b.jpg");'>
12 <img src='1772031_53_t.jpg' onclick='changeImage("1772031_53_b.jpg");'>
13</div>
14