<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <title>ttt</title> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1251"> <script type="text/javascript"> onload=function(){ var allPic, k; allPic=document.getElementById("cont").getElementsByTagName("img"); k=allPic.length; while(k--){allPic[k].onclick=myClick;}; }; function myClick(){ document.getElementById("elem").innerHTML='<img src="'+this.src+'" alt="">'; }; </script> </head> <body> <div id="elem"></div> <br> <div id="cont"> <img src="1.gif" alt=""> <img src="pict1.jpg" alt=""> <img src="pict2.jpg" alt=""> </div> </body> </html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html><head> </head><body> <div id='main'></div> <div id='pic'> <img src='http://javascript.ru/forum/image.php?u=12890&dateline=1303149256'> <img src='http://javascript.ru/forum/image.php?u=19820&dateline=1334914235'> </div> <script> var pic = document.getElementById('pic').getElementsByTagName('img'); for(i=0;i<pic.length;i++) { *!* pic[i].onclick=function() { change(this.src); } */!* } function change(s) { document.getElementById('main').innerHTML = '<img src='+s+'>'; } </script> </body></html>